Using sfAmfPlugin part 1

22. August 2008 in Flex, Symfony

As I wrote in my last blog article I on my way to develop my first Symfony application with a Flex fronten. Therefore I’m developing my own Symfony plugin to handle AMF-Service-Calls from the client. For my first steps I used the AMF-PHP library what worked great but has one really big drawback: It has a GPL-License. Cause I developing in a commercial environment GPL isn’t pretty useful for a library. After some googling around a found SabreAMF. SabreAMF is also written in PHP but is more a low level library. But it is fitting my needs so i used it for the first public available version of my Symfony plugin.

Where to start?

First visit the Plugin-Homepage at the Symfony project. There you will find a Subversion-Repository where you can checkout the latest version of the plugin. Copy the checked out sources to the plugin folder of your project. After a “symfony cc” the plugin is ready to use.

All your services you can call will need to be saved under lib/services in your project folder. There you can add as many subfolders as you need/want. Services on Flex-Side can use package names like You can use this with symfony too. All you need to do is to save this Service under lib/services/org/company/project/Servicename.php. That’s it!

class TestService extends sfAmfService {
    public function getValues() {
       return array('value1', 'value2', 'value3');

But how is this service called? We need an URL to do so. For symfony this means you need a module and an action. The following listing shows you how an AMF action should look like:

    public function executeAmf() {

        $gateway = new sfAmfGateway();
        $response = sfContext::GetInstance()->getResponse();
        return sfView::NONE;

Thats should be all for today. If you have any ideas, wishes or bugs just write a comment.

Whats coming?

I’m already working on a new version of the plugin. There is my own little wishlist:

  • PEAR packaging, so you can install it with the symfony installer
  • Improved support for Doctrine and Propel
  • Better integration in Symfony
  • Annotations for the Service-Methods (i.e. authorization, Class binding and so on)

5 responses to Using sfAmfPlugin part 1

  1. Very cool! This is exactly what I hoped SabreAMF would be used for..

    Let me know if there are any annoyances in integrating the API into symphony or workarounds you’ll need to do, to get the job done..

  2. Hi Evert,

    SabreAMF is working like a charm. No problems at the moment. Thanks for your work :-)

    BTW: I just saw your SabreDAV project. Looks pretty good! If auth is implemented I will use it for one of my projects.


  3. hi, how exactly do i call the service from flex ? using a httpservice object ?

  4. Hi,
    It’s great to meet your blog about symfony n flex. I’m about to start my first application with flex on symfony. Can I have your complete or sample code about communication flex – PHP on AMF? Thx…

Leave a reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>