Dec 18, 2009

Zend AMF Is Easy

When it was announced a while back that Zend was going to include AMF (Action Message Format) functionality supported by Adobe, I was excited to hear that there would be an "official" way to use AMF with PHP, as I had used AMFPHP, an unsupported implementation, with mixed success. I experimented with Zend AMF a little when it was released, and there were two things that annoyed me about this implementation as compared with AMFPHP, but I revisited it this week and discovered remedies for both issues.

My first issue was the size of the code library. The full Zend Framework is around 27mb, while AMFPHP weighed in at 1.4mb. I had read that you didn't need the whole framework to use Zend AMF, but couldn't find details on how to slim it down. This week I found a link that offered the ability to download only Zend AMF. I downloaded and installed, but when I navigated to my gateway in a browser, I was greeted with an error claiming a necessary class could not be found. I found this class in the full Zend directory and copied it over to my Zend AMF install, worried that I was embarking down what could be an endless road of error, copy files, repeat. This road only ended up being one directory and one file long, and then I had Zend AMF working at a slim 754kb. I ended up needing to move the Loader directory and the Auth.php file to get it working. I am not sure why these were left out of the Zend AMF download.

My second issue was the lack of a service browser app like the one included with AMFPHP. My new friend Garth alerted me to the fact that one of the guys over at almer/blank in Los Angeles had recently released a service browser for Zend AMF in the form of an AIR application called ZamfBrowser. It works great so far, and even lets you easily send custom objects as parameters to the remote methods, something that was more difficult with the AMFPHP version. My only suggestion at this point would be the addition of a 'Refresh' button to allow the services to reload after making a change to the code.

Share this Post


                           

Comments


SJL Perth     May 14, 2010
Thanks for sharing this with us Josh, I'm just starting out with the Zend library and I will give AMF a whirl this weekend.

Peter     Mar 01, 2010
Its a little bit too slow but a really good thing.

Dom Tancredi     Feb 09, 2010
Great post! I concur with Charles Web Proxy (http://www.charlesproxy.com/) for your service-based trouble-shooting needs. No need to use a service browser with that guy helping you out.

I've been using AMFPHP for a while now for Flash + Flex-based projects, and getting the objects to serialize properly has always been tricky, but worth it. Especially in Flex.

Lastly, check out CodeIgnitor (and Kohana - http://www.kohanaphp.com/) for possible architecting ZendAMF

If you're working with some monster DAO's, totally recommend DAOGenerator. http://titaniclinux.net/daogen/

Big fan of you guys!

Dom

oyunyolu     Feb 02, 2010
Josh

Easy, but sloooow

maurice coquine     Jan 28, 2010
Well thank you very much for your contribution.
I experienced the exact same problems as you with Zend AMF . The only difference is that I got much of my inspiration for you.
I helped a lot, it´s terrific!
Now it is running perfectly and I should I really like it.

Matt Johnson     Jan 08, 2010
We've been using the Zend AMF package on a number of websites recently with great results. I've written an article over at the CodeIgniter Wiki on integrating it with that framework. It ends up being a really nice combination to work with, especially when you leverage an MVC model as your AMF base class.

http://codeigniter.com
http://codeigniter.com/wiki/AMF_Flash_Remoting_with_Zend_and_CI/

Brady White     Jan 07, 2010
We use Charles Web Debugging proxy which is the best web services debugger for AMF that I have seen. Check it out:
http://www.charlesproxy.com/

- Brady

Reinhold Burger     Jan 07, 2010
Thanks for sharing your experiences, im just about to start dabbling about with zend amf myself.

Tony Bibbs     Dec 28, 2009
I'm not assuming you aren't doing anything of these but to be clear:

ZF Size: don't like it? Created a .bz2 PHAR archive of ZF (assumes PHP 5.3.0+)
Speed: of course add opcode caching and consider use of a properly cache library.

What you don't get with other libraries is the Zend stamp, which to many may not mean much, however, with regard to ZF it means the shit was tested out of it. Not to mention it's author is an Iowan which is just another plus ;-)

--Tony

oyunlar     Dec 23, 2009
Great article. I haven't used ZendAMF yet. I am not sure why these were left out of the Zend AMF download.

Tink     Dec 22, 2009
Aight Josh

Easy, but sloooooooooooooooooow

http://framework.zend.com/issues/browse/ZF-7493

Stephen     Dec 21, 2009
Great article. I haven't used ZendAMF yet, as AMFPHP has been adequate and blazingly fast, so it will be interesting to see how it compares.

Cheers.

Martin Sandström     Dec 20, 2009
Have you guys checked out SabreAMF? Its alot smaller then the Zend implementation and very easy to install.
http://code.google.com/p/sabreamf/

/ M

burak özdelice     Dec 19, 2009
Thanks for the news Joshua. I've been recently started to struggle with drupal amfphp lovers and Zend AMF as you said above was far to me too. I will definitely try.

and thank you Sarith for guides.

Josh     Dec 18, 2009
thanks for the comment, Sarith.

That link for downloading Zend AMF as a standalone package is the same one I reference in my post above. It didn't work until I moved a couple of files from the full Zend framework into it.

I have been using the FB4 beta for a while, but have not played with the PHP wizard yet. I will be sure to check it out.

Sarith Demuni     Dec 18, 2009
Hey Josh,

First of all-- big fan of you and the entire Big Spaceship crew. Great work!

Secondly, not sure if you've stumbled across this already but the AMF library (along with all necessary libraries for use with your ActionScript implementation) can be found as a standalone package here: http://framework.zend.com/download/amf

Also, again not sure if you've seen this already, but ZendAMF support is being bundled together for use with Flash Builder 4 right out of the gate. You can check out the beta here: http://labs.adobe.com/technologies/flashbuilder4/

The coolest part is probably that setting up PHP services for integration with ActionScript (using AMF) is now a pretty automated process. In FB4, there's a wizard that will set up all your base code, includes, and file/directory structure with a few clicks. Obviously, for extremely custom implementations, this probably won't be the way to go-- but for most purposes it gets the job done quite well.

And yes, in conjunction with almer/blank's browser app, it's really quite a fantastic solution.

Best regards, and I'll see you in a couple of months when I apply for a job :)

S


Speak






Submit »