Flex 2 RemoteObject with AMFPHP supporting AMF3

Posted on December 12, 2006 | 14 comments

Patrick Mineault has created an alpha update of AMFPHP that now supports AMF3. He is looking for people to test it out. To help with this I have created two simple examples that I have running live on a PHP4/Apache server, as well as have tested on a PHP5/Windows box.

Basic Example
Return Array of VO’s Example

You can download the source for both examples by right clicking on the apps or get it here.

Note: To make the amfphp 1.9 alpha code to work with PHP4 there you need to implement a different function for the array_search() when the search needle is a object.

  • Pingback: Leonardo França » AMFPHP com suporte a AMF3

  • luchyx

    Hi renaun
    Can you give some suggestion to get work the -service config with your remote object. ?
    I’ve got this command “-locale en_US -services services-config.xml” in my project but the endpoint is not replaced.
    I’m using php4, amfphp0 and .


  • http://www.renaun.com Renaun Erickson


    You are almost there, use the source from my xml config file.

    In my example i was using a file called “amfphp19-services-config.xml”. In the mxmlc compile arugments list I add “-services amfphp19-services-config.xml”.

    You can find the source here:

  • luchyx

    Yes I’m was reading the doc’s and your examples; looks easy but I don´t know what happens.
    I’m using cairgorm 2.1. Did you try with it ?
    // I can’t paste directly the mxml source, I hope the html work!.

    <rpc:RemoteObjectAMF0 endpoint="http://localhost/amfphp/gateway.php"
    id="usersServices" makeObjectsBindable="true"
    source="com.ria.CategoryManager" requestTimeout="30" showBusyCursor="true"/>

    And in the services-config.xml I modify the endpoint

    <destination id="userService">
    <channel ref="amfphp"/>
    <channel-definition id="amfphp" class="mx.messaging.channels.AMFChannel">
    <endpoint uri="http://otherhost/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>

    The endpoint never change according the service-config.xml, Weird.!

    Thanks a lot.

  • http://www.renaun.com Renaun Erickson

    With AMF3 support you do not need to use the RemoteObjectAMF0 but use the normal Flex RemoteObject.

    You can set the endpoint through the compile -services argument or specify the endpoint in each RemoteObject. The compiler method is the standard but not necessary a have to.

  • http://www.t8design.com Wade Arnold

    Renaun, I was hoping that in your second example you would actually use a delegate and have it follow cairgorm. Any chance for us getting a good example of Service Locater?As always thanks!

  • Suresh


    Is there a good tool for us Java folks, other than Flex FDS. OpenAMF has non-existent documentation and I am not sure if it supports AMF3.

  • http://www.renaun.com Renaun Erickson

    Short answer not really

    Red5 (not complete feature set, more Flash Media Server)
    WebORB from midnight coders (.NET implementation and other languages coming)

  • Stefan Schmalhaus

    Since _authenticate() and roles have been removed from AMFPHP 1.9 I don’t know how to secure my remote services. How can I read the setCredentials() header in 1.9?

  • http://www.renaun.com Renaun Erickson

    not sure, it should be readable out of the headers like you are referring too.

  • Stefan Schmalhaus

    If I were able to read the credentials header in AMFPHP 1.9 I could probably set up my own authentication procedure. But I don’t know where to patch Patrick’s scripts.

  • Dan Van Brunt

    Great work Renaun. Your site has been very helpful to me. I’m new to Flex and I seem to be having a bit of difficulty finding good examples.

    I your “Flex 2 RemoteObject with AMFPHP supporting AMF3″ example…however…do you/ or anyone else….know of an example that shows not only passing VOs from PHP to AS3 but also the reverse?

  • http://www.renaun.com Renaun Erickson

    The reverse requires the PHP class to be part of the gateway.php’s “setClassMappingsPath()” so when AMFPHP tries to deserialize the AMF code defined by the AS3 class it can find a class to map too.

    Here is a link that explains it:


  • Sandip

    I need help or may be tutorial on flex + cairngorm + red5 + java

    Can anybody help me with the basic example.

    My remoteobject in red 5 is not wrking in cairngorm. Otherwise it works

  • Tejas Patel

    Hello Renaun Erickson,
    Thanks a lot.
    I got solution of my problem by this tutorial.
    Let’s get acquainted!!!