Symfony-Zone | Timo Haberkern blogs about symfony

Aug/08

22

Using sfAmfPlugin part 1

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 org.company.project.Servicename. 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() {
        $this->setLayout(false);

        $gateway = new sfAmfGateway();
        $response = sfContext::GetInstance()->getResponse();
        $response->setContent($gateway->service());
        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)

No tags

7 comments

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me