Amfphp 1.9 beta – Get it now

Posted on

Well I’ve been working on the new version of amfphp for about a week now, and it’s ready for a test-drive. I’ve had the feedback I needed from the alpha, and I am fairly convinced this new version works like a charm. You can download it here. This time it should work with PHP4.

What’s new

  • AMF3 support, including RemoteObject. You can finally use it in Flex 2.
  • JSON support. In addition to gateway.php, there is now json.php which allows you to use your services in JSON as well Flash. Two examples here: MochiKit and Spry. XML-RPC also supported. Details below.
  • A new Service Browser. Try it live here. Notice that the samples.MochiTest service is the same one used by the JSON sample, so you can verify for yourself that indeed it works both in AMF and in JSON mode. Fuggawesome.
  • The end of $this->methodTable. From now on, $this->methodTable is ignored. All methods are remotely accessible by default. Details below.

Getting it running in Flex 2

This has nothing to do with amfphp per-say, but to get RemoteObject running, you need to configure the Flex compiler by doing the following:

  • In you source folder, create the services-config.xml file. Paste this in (You can change the uri of the endpoint if you wish):

<?xml version=”1.0″ encoding=”UTF-8″?>
<service id=”amfphp-flashremoting-service”
<destination id=”amfphp”>
<channel ref=”my-amfphp”/>

<channel-definition id=”my-amfphp” class=”mx.messaging.channels.AMFChannel”>
<endpoint uri=”http://localhost/amfphp/gateway.php” class=”flex.messaging.endpoints.AMFEndpoint”/>

  • Right-click your project in Flex Builder 2 in the Navigator, go to Flex Compiler, and add -services "services-config.xml" to Additional compiler arguments. Press OK.
  • You can override the gateway location in RemoteObject if you want by setting the endpoint property in the MXML. This is good as you have to clean your project in order for changes to services-config.xml to be caught by the compiler, which means rebuild from scratch. Also, that XML file is painful to look at compared to good old mxml.