Home > AMFPHP, Zend_Amf > Zend AMF updates and questions for AMFPHP users

Zend AMF updates and questions for AMFPHP users

December 16th, 2008

I have been cleaning up some code and test cases in Zend Amf before some more real development starts. If you had issues with class and method collision, ByteArray’s, array’s loosing there keys, documents, or not getting the errors that you wanted please check out the latest build. Also if you have any feature request or bugs please make sure you let me know! 

Zend Framework Issue Tracker for AMF

Next up is optimizing ArrayCollection and proxy object support. 

If you used returning native resources in AMFPHP can you please let me know which ones. 

One of the most impressive features of Flash remoting is the ease at which you can send back resultsets. AMFPHP is preloaded with a set of adapters for a variety of databases and database drivers, in particular:

  • MySQL
  • PostgreSQL
  • SQLite
  • MySQLi
  • MsSQL
  • ADODB
  • ODBC
  • Oracle (oci8 for PHP5)
  • PDO
  • PEAR::DB

AMFPHP, Zend_Amf

  1. December 17th, 2008 at 03:33 | #1

    I’ve been keeping my eye on this, but recently read that the Zend Framework requires PHP5. Unfortunately the production server’s we have are still only offering PHP4

  2. December 17th, 2008 at 04:27 | #2

    I’m using Zend_Amf 1.7.1 and I have problem with ByteArray and rest params. When I send ByteArray and rest params to php, I have one array with all params instead of two or more function params. My client is flash 9 with NetConnection object.

  3. evans
    December 17th, 2008 at 06:20 | #3

    First, thanks for the work you do. I’m not a pro (just an ambitious amateur who does free work for small nonprofits) and I couldn’t do what I do without freebies like amfphp.

    A quick question, then: do you have an ETA on amfphp 2? I can’t wait to use it.

    Thanks again.

  4. December 17th, 2008 at 06:46 | #4

    @lee
    @lee You really need to come up with an upgrade plan, then. PHP 4 was end-of-lifed this past August. There will be _no_ more security updates whatsoever; the longer you stay on it, the more risk you put to your site and your data.

  5. December 17th, 2008 at 10:33 | #5

    @lee PHP4 is end of life tell those admins to keep off there buts and upgrade to php 5 before it is end of life!

  6. December 17th, 2008 at 10:34 | #6

    @Zwolu Can you open up a bug and show code. That should work!

  7. Brendan
    December 17th, 2008 at 10:56 | #7

    Hi. This may be a dumb question but i’m an apache/php newbie. I’m using index.php to facilitate the zend_amf server (as in all the examples) and it works great … so where do I put my website’s main default page (ie index.html, index.php)? If I try putting an index.html page on my server the zend_amf stuff stops working. Any help would be great – thanks…

  8. December 17th, 2008 at 11:02 | #8

    Sweet. Thanks Wade.

  9. December 17th, 2008 at 14:59 | #9

    @Wade,
    We are using Zend Framework for our product, but use AMFPHP for the Flex front ends and applications. We are also on the verge of developing an AIR application which will again works closely with the online product, which needs high end syncing of the database, and sometime some heavy content. Just thinking to move to Zend AMF, but would like to know whether it will be stable, and is it going to break what I could do with AMFPHP… some doubts in the mind…

  10. December 17th, 2008 at 15:36 | #10

    @Brendan Check out this post http://wadearnold.com/blog/?p=99 should get you going in the right direction.

  11. December 17th, 2008 at 15:36 | #11

    @Vipin Zend is more stable than AMFPHP at this point. It is still missing a couple features but all the documented features are fully unit tested.

  12. December 17th, 2008 at 15:37 | #12

    @Garth Braithwaite No problem Garth.. I am always working on ZAMF for you!

  13. December 18th, 2008 at 16:09 | #13

    Wade,

    I just downloaded the latest build in hopes it would fix the following.
    FaultEvent fault=[RPC Fault faultString=”Duplicate method registered: setTableName” faultCode=”0″ faultDetail=”#0 /Applications/MAMP/frameworks/Zend/Amf/Server.php(442): Zend_Amf_Server->_buildDispatchTable()

    but no luck. I’ve commented out all my code to Zend_Auth_Adapter_DbTable and I still get the error above.
    Not sure what I’m doing wrong.

  14. December 18th, 2008 at 16:21 | #14

    @Wade – I use ArrayCollection often as well as ObjectProxy occasionally. The new Zend_AMF has really nice support for VOs. Much appreciated!

  15. December 18th, 2008 at 21:46 | #15

    @Keith Craigo Looks like the same error that was just resolved. The only file affected for this fix is Zend_Amf_Server. Can you just download that from SVN and double check that it does not solve your issue.

  16. December 18th, 2008 at 21:47 | #16

    @Rob Taylor Working on even better support for both of those coming from Flex to the client. There is a Zend_Amf_Value_ArrayCollection that will be in the next minor release.

  17. December 19th, 2008 at 06:19 | #17

    @Wade – What about support for using credentials in AMF headers? Older versions of AMFPHP supported a credentials/role concept. Or are there any plans of integrating Zend_Amf with Zend_Acl? Thanks.

  18. December 20th, 2008 at 16:22 | #18

    Wade,
    As it turns out your library is working as it should. The problem was the guy behind the keyboard here. I didn’t completely understand how to implement it. All is well now.

    Thank you

    Keith

  19. Nelson Cano
    December 26th, 2008 at 21:16 | #19

    Hello. I currently developing applications with Zend in the backend and the client Extjs (I play that I do not like no Ext JavaScript library) and Flex development when (if I like this) I do it with PHP via AMFPHP (Me Like in most developing flex than anywhere else) and now that I am very happy Zend_AMF out moving around as I want at this point in my whole Flex, Zend and Doctrine. Only strange AMFPHP browser classes that allowed me to test the response of the classes conducted in PHP quickly Zend_Amf Will that will take account of a browser or something?

  20. David
    January 3rd, 2009 at 11:23 | #20

    Hi. I am having trouble passing arrays and objects from Flash to AMF (interestingly, I can get associative arrays back from a database via AMF to Flash without problem). I updated AMF to the latest build via the above link, and it still doesn’t work. I am using WAMP, Windows XP (latest service pack), ActionScript 3.0, and Flash CS3.

    I am using NetConnection in my “SendData” class and when I send a series of two strings, it works fine. If I substitute the second string variable for a simple array (myArray = [1, 2, 3]) or a simple object (myObject = {a:”foo”, b:”bar”}) I get a “bad call” error. The PHP code is very simple, and the variable names/types are changed accordingly to accomodate the different variables.

    I would suspect that passing arrays and objects to AMF has been tested and am puzzled why I can’t get this to work. Help on this issue is sparse on the web at this point– I checked the bug list and noticed that passing an object as the first variable is a problem, but I can’t get it to work at all, even in the second position. Any help/advice would be greatly appreciated!

    Thanks,
    David

  21. January 4th, 2009 at 08:27 | #21

    I’m sure everyone is asking already, but definitely looking forward to a service browser similar to that of amfphp. Anyway, just wanna say thanks for the good work :)

  22. David
    January 4th, 2009 at 12:50 | #22

    Actually, I get a “bad version” error, not a “bad call” error. I hope I can get this issue resolved. I’m at a production standstill. I’m still working on getting the unit tests configured (from the other thread).

    Thanks,
    David

  23. January 5th, 2009 at 00:10 | #23

    @Nelson Cano There is work on a universal remoting service browser. Most of the work that I am currently doing is for integration with eclipse for Flex Builder 4.

  24. January 5th, 2009 at 00:13 | #24

    @David The issue that you are describing can’t be an issues with Zend Amf. There would be a 10k people ranting on my blog. I sent you an email asking you to zip up as small of an example as possible including your bootstrap file and I will check it out to get you un-blocked.

  25. Jesper Stærkær
    January 5th, 2009 at 10:59 | #25

    I’m am having trouble with passing Vo from Flex to the server. I can send both integers, booleans, string and array, but not my custom Vo. I have tried to use both $_explicitType inside the VO-class and $server->setClassMap(); inside the bootstrap.
    The other methods in my service, sending the similar object _from_ the server to Flex are working just fine. Flex is reciving objects with the right datatype, so all the mapping and linking _should_ be working.

    I used Charles to get this error from PHP:

    Fatal error: Uncaught exception ‘Zend_Amf_Exception’ with message ‘Unable to parse null body data net.cmplx.Vo.CategoryStructureVo mapped class cmplx_Vo_Category_StructureNodeVo is not defined’ in [...]Zend/Amf/Request.php:174
    Stack trace:
    #0 [...]Zend/Amf/Request.php(125): Zend_Amf_Request->readBody()
    #1 [...]Zend/Amf/Request.php(93): Zend_Amf_Request->readMessage(Object(Zend_Amf_Parse_InputStream))
    #2 [...]Zend/Amf/Request/Http.php(64): Zend_Amf_Request->initialize(‘????????null??/…’)
    #3 [...]Zend/Amf/Server.php(427): Zend_Amf_Request_Http->__construct()
    #4 [...]Zend/Amf/Server.php(369): Zend_Amf_Server->getRequest()
    #5 [...]services/flexamf.php(25): Zend_Amf_Server->handle()
    #6 in [...]Amf/Request.php on line 174

    Have read allmost every article and tutorial posted on Zend_Amf, not finding a similar case or code-example. After hours of digging further down into the Zend Framework, failsearching, I gave up.

    Excuse me for posting here if it’s not the right place to ask for help. Appreciate any kind of respons. Best regards.

  26. tzor
    January 5th, 2009 at 11:42 | #26

    Hi there! First of all, thanks for your commitment to this project.

    I’ve got a complex object with circular references:
    A ->B
    B->A
    B->C
    C->B

    I need this to be transmitted from AS to php, in both directions. Is this kind of thing properly handled by Zend_Amf ? Thank you.

  27. David
    January 5th, 2009 at 16:10 | #27

    Thanks for the support, Wade! I sent the email today. Wow, I am impressed with your dedication!!!

  28. January 5th, 2009 at 16:31 | #28

    @tzor It should work just fine. However if it does not please send me your code as it should or just open a bug with the snippet.

  29. January 5th, 2009 at 16:33 | #29

    @Jesper Stærkær SetClassMap is the only way to define sending a class mapped object from flex to php. All the other methods are just for returning objects. I sent you an email!

  30. Jesper Stærkær
    January 5th, 2009 at 19:12 | #30

    Thaks alot. I used the setDirectory instead of the addClass. How come this method isn’t working? What kind of function do the addClass have, if we hav eto hardcode both loading and classmapping in the bootstrapper in any case?

    Anyways, thaks a million times. I really like Zend_Amf. This technology is fantastic. Keep up the good work, many many developers appreciate your efford.

  31. January 5th, 2009 at 22:08 | #31

    @Jesper Stærkær setDirectory and setClass should work exactly the same. I am not sure what you mean by addClass? You are always going to have to set you mappings for any flex endpoint on the server to send a vo from flex to the server. Blase DS and Life Cycle use and an XML file for the definitions. It has been suggested before to add such a config file to zend amf but there has never been a rally for such a thing as the majority of people just return vo’s rather than send. Probably because you should not trust a VO coming from Flex so then you need to validate it and casting from there is just one more little step.

  32. January 18th, 2009 at 05:47 | #32

    Hey Wade…
    just curious,

    (1) — under AMFPHP 1.9 with AMF3, there’s an issue with sparse arrays failing to come across as numerically indexed if their first [0] field is null…I’m wondering if the new parser ever addressed that…

    (2) — Also, does the new Zend_Amf support the AMFEXT php mod like 1.9 did? Or is there some kind of c-compiled service that lets it run as fast as that did? It seems like the amfext project’s been pretty much dead for the past few years, but it’s a speed monster…it makes AMFPHP as good as or better than running sockets in some cases…

  33. January 20th, 2009 at 07:33 | #33

    Wade, you never answer my questions man. Do you know I field inquiries from people trying to grapple with these AMF3 bugs all the time, and I have nothing to tell them except, use AMF0, or go with a bundled associative array instead of returning sparse arrays, bytearrays or mysql result sets directly? And half the time that stuff doesn’t even work. I know you took over the AMF project so I’m not laying blame or anything, but ignoring the fact that these issues exist doesn’t do anyone much good, does it?

  34. January 20th, 2009 at 15:38 | #34

    @joshstrike 1. I am not sure if that still exists but if it does open a bug. The parsing is massively different in Zend Amf than in AMFPHP.

    2. Amfext is not support. Although it would be pretty simple to add the issue is that there are a couple bugs with amfext that would need to be addressed before it could pass the coding standards of the Zend Framework. The AMFEXT would need to create the exact same output as not using to pass all the same unit tests. The current focus is to getting any minimal issues resolved so that we are 100% stable for enterprise production before we put any reasources onto optimization.

    I am not sure what your AMF3 bug is but if you want to open a bug in the zend framework project please due. Everything is getting completed in about 3-5 weeks that has been submitted.

  35. January 20th, 2009 at 17:17 | #35

    I used AMFPHP alot and got use to building the service classes with similar CRUD methods. I’ve tried to follow the same model in ZendAMF, but keep getting the “Duplicate method registered” exception. Can you not have two different services with the same method names? ie: ProjectService.getAll() and UserService.getAll()

  36. geor
    February 8th, 2009 at 03:30 | #36

    Hey Wade. Thanks for work on the project.
    Do you think it’s possible to use zend_amf without ZEND framework, or you would suggest to stay with AMFPHP. You say that ZEND AMF is more stable than AMFPHP at this point so I wonder if an attempt to cut out Zend_Amf from the whole framework is worth the effort.
    Yes I know zend framework is great by itself but I just don’t want it.

  37. February 9th, 2009 at 10:31 | #37

    Zend Framework is a use at will framework so yes tear it apart! I will write a blog post this week on how to do it.

  38. February 9th, 2009 at 10:38 | #38

    @Jesper Stærkær Please check the latest release from SVN. This issue has been solved. It will be in the 1.7.4 release.

  39. geor
    February 23rd, 2009 at 18:13 | #39

    @wadearnold
    Thanks for answer :) . Did you find time to write blog post on tearing them apart. I did’t manage to find it. Anyway thanks :) I’ll try to do it.

  40. March 6th, 2009 at 00:13 | #40

    dustin :
    I used AMFPHP alot and got use to building the service classes with similar CRUD methods. I’ve tried to follow the same model in ZendAMF, but keep getting the “Duplicate method registered” exception. Can you not have two different services with the same method names? ie: ProjectService.getAll() and UserService.getAll()

    I am doing the same thing and getting the same error? Why wouldn’t this be allowed? Aren’t the methods scoped only to their class?

  41. goliath
    March 17th, 2009 at 16:37 | #41

    i might be a bit too late, but could i have the info you gave to Jesper? O-)

    i’ve been fighting with the “Unable to parse null body data mapped class is not defined” for 3 days.

    ZF 1.7.2 had it. I switched to 1.7.7. It’s still there.
    You can easily get VOs out from a ZendAMF gateway, but how do you get them past ‘into’ it?

    >>Probably because you should not trust a VO coming from Flex…
    You shouldn’t and mustn’t. But, being a lazy developer (and maybe following “promoted” ‘best-practices’) you don’t want to pass an object as a bunch of params to a method.

    To be more specific, in a futile attempt to get some skills, i’m trying to put together a simple ‘music album management app’ (simple CRUD). Listing the albums (and mapping PHP-VOs to Flex-VOs) wasn’t a problem.
    What you want to do now – is create the entry in the db-table, and, have
    Something like: Flex->ZendAMF->Albums->

  42. goliath
    March 17th, 2009 at 16:49 | #42

    i might be a bit too late, but could i have the info you gave to Jesper? O-)

    i’ve been fighting with the “Unable to parse null body data <Flex alias VO for PHP> mapped class <PHP VO> is not defined” for 3 days.

    ZF 1.7.2 had it. I switched to 1.7.7. It’s still there.
    You can easily get VOs out from a ZendAMF gateway, but how do you get them past ‘into’ it?

    >>Probably because you should not trust a VO coming from Flex…
    You shouldn’t and mustn’t. But, being a lazy developer (and maybe following “promoted” ‘best-practices’) you don’t want to pass an object as a bunch of params to a method.

    To be more specific, in a futile attempt to get some skills, i’m trying to put together a simple ‘music album management app’ (simple CRUD). Listing the albums (and mapping PHP-VOs to Flex-VOs) wasn’t a problem.
    What you want to do now – is create the entry in the db-table, and, quite trivially, have something like:
    Flex->ZendAMF->Albums->addAlbum(VOAlbum)
    and not like
    Flex->ZendAMF->Albums->addAlbum(id, title, artist, year)

    Of course, inside of the ‘addAlbum’ method, you do all kinds of checks, validation, sql screening, etc.

    If the VO doesn’t really have many properties, then it’s not too tough to type them all into params of the method. But, when you’re not quite sure about your VO, its params, the order of the params, the number of props in your VO scrolls down 2 pages or you’re that ‘confused over life’ person like me, then it becomes a mess and a headache.

    Really a deadpoint…

    my finger slipped – please delete my previous post O-)

  43. goliath
    March 26th, 2009 at 06:45 | #43

    It seems i have found a possible fix (/my mistake) to “Unable to parse null body data mapped class is not defined” error.

    i was using “$server->addDirectory(‘../Common’)” and thus, expecting that no ‘require_once’ statements for VOs will be necessary (since those actually appear within the ’service’ class).

    Well, as soon as i added ‘require_once VOAlbum.php’ to the top of the file – everything worked – Zend Amf got the typed data (‘addAlbum (VOAlbum)’).

    The other way to do it – is through the ‘include_path’ like:
    $inc_paths = array();
    $inc_paths[] = ‘../../libs/ZF/1.7.7/library/’;
    $inc_paths[] = ‘../Common/’;
    $inc_paths[] = get_include_path();
    $inc_paths = implode(PATH_SEPARATOR, $inc_paths);
    set_include_path( $inc_paths );

    Both seem to work fine.

    Sorry for causing confusion, Wade O-)

    Hope this helps someone save some time and nerves.

  44. June 5th, 2009 at 21:08 | #44

    Wade do you have any benchmark tests for ZendAmf and AMFPHP?
    I’d like to see them.
    To me I don’t really see a reason to move to ZendAmf.
    Do you mind giving some benefits?

    It would be much appreciated!

    -Alrick

  45. Ben
    August 11th, 2009 at 10:15 | #45

    @David
    I am having the exact same problem as well, did you ever get this figured out? I know its nothing in my PHP logic, nor the AS3 code. I call the same function but pass it something other than an array, it works. I pass an array and I get a CallBadVersion error.

  46. Ben
    August 11th, 2009 at 13:59 | #46

    @Ben
    Interestingly enough, I change the default encoding to AMF0 and it works. Seems to be a problem. I am currently using Zend 1.8.

  47. Andros
    October 7th, 2009 at 10:23 | #47

    To give Alrick’s post a Bump..

    Wade do you have any benchmark tests for ZendAmf and AMFPHP?
    I’d like to see them.

    Do you mind giving some benefits?
    My personal case is working strictly in Flash AS3 ( not flex )

  1. No trackbacks yet.