Development

sfAmfphpPlugin

You must first sign up to be able to contribute.

sfAmfphp plugin

Plugin that bridges AMFPHP functionality into symfony.

Currently very 'hello world', but a good starting point.

Installation

Currently, your best bet is to check it out (or svn:external) into your plugins directory. The SVN repo is at:

$ cd plugins/
$ svn co http://svn.symfony-project.com/plugins/sfAmfphpPlugin/ .

Note: make sure the folder is called 'sfAmfphpPlugin' - it's for autoloading reason for now.

Use

  1. Create a module as your Gateway
  2. Configure the gateway action. A barebones implementation is:
<?php
public function executeAmfphp()
{    
    sfConfig::set('sf_web_debug', false);
    $this->setLayout(false);

    $gateway = new sfAmfphpGateway();
    //For a full and real interaction with symfony (headers for authenticated users)
    $response = sfContext::GetInstance()->getResponse();
    ob_start();
    //Serve the AMF Request
    $gateway->service();
    $response->setContent(ob_get_contents());
    //Don't use ob_end_clean() not ob_get_clean() since this will kill symfony own headers
    ob_clean();
    //The response content is automatically sent by symfony, so no need for a $response->sendContent();
    return sfView::NONE;
}

sfAmfphpGatway extends Gateway, so you can call any method that you need to customise it the way you normally would.

  1. Create your services folder in lib/ (er, so you'll have: lib/services/
  2. Create a service as you normally would, say, lib/services/HelloWorld.php:
<?php
class HelloWorld
{
    function HelloWorld()
    {
        $this->methodTable = array
        (
            "say" => array
            (
                "access" => "remote",
                "description" => "Pings back a message"
            )
        );
    }
 
    function say($sMessage)
    {
        return 'You said: ' . $sMessage;
    }
}

  1. In Flash, create a blank document and put this on the first frame in the timeline:
import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;

var gatewayUrl:String = "http://amfphp/test/amfphp"

NetDebug.initialize();
var _service:Service = new Service(gatewayUrl, null, 'HelloWorld', null , null);
var pc:PendingCall = _service.say('sup');
pc.responder = new RelayResponder(this, "handleResult", "handleError");

function handleResult(re:ResultEvent)
{
    trace('The result is: ' + re.result);
}

function handleError(fe:FaultEvent)
{
    trace('There has been an error');
}

(customise the gatewayUrl, you'll probably have to..)

  1. Hope that you get the following output in your trace window:
    The result is: You said: sup
    

If you get weird messages that it can't find some libraries and whatnot, take a look over here, and look for the link to mx.zip.

Contacts

TODO

  • More testing! Find out what doesn't work, implement it.
  • Create default gateway route/module/action.

Changelog

2007-10-04 | 0.0.1 Alpha

  • First public release.