Search Flex Components Free

Custom Search

December 9, 2007

AMFPHP - The Flashiest PHP Class Library Yet

from: amfphp docs. The second page of this document includes an overview of using web services with amfphp. For even more up to date information, please visit us on the AMFPHP message board.


Flash Remoting is client/server framework designed to ease data exchange between a server and the Flash client, using AMF, an exchange format inspired by SOAP.

AMFPHP is the open-source Flash Remoting gateway for PHP.

The need for Remoting

Let’s say you want to exchange data between Flash and a server. A common method is to use XML. Actionscript has a built-in XML parser, so you can load XML files directly from the server and read the data that’s inside. But what if you wanted to get data from a database? What developers used to do is create, for example, a PHP page, connect to a database, make a query, loop through its elements, create a long XML string out of the data, and send it back to Flash. Back in Flash, the inverse process would be done: get back Flash-readable data from an XML file by working to the DOM.

What’s wrong with this process? Well it is a tremendous waste of time; a lot of resources are wasted figuring out what schema to use, implementing code on server and client, and debugging. All of this for the purpose of constructing something on the server that you immediately destruct on the client side.

Enter Flash Remoting

Flash remoting is a toolkit including a server gateway, components, actionscript classes and a debugger. On the Flash side, you have a bunch of actionscript classes that handle decoding and encoding data. You have a gateway on the server side that also encodes and decodes messages and acts as a dispatcher to call the required service. Data is exchanged in the AMF format, which is a binary format inspired by SOAP. The gateway and the actionscript classes translate data into this neutral format, and this allows language specific data to be exchanged transparently. The bottom line: exchanging data between Flash and the server is fast and simple.

AMFPHP versus other implementations of Remoting

Most implementations of Flash Remoting (with the notable exception of FlashORB) use Remoting-specific objects and structures on the server side. For example, MM’s .NET implementation uses ASObject to wrap actionscript objects, and ColdFusion has a Flash struct to handle things like pagesize.

AMFPHP, on the other hand, was created with interoperability in mind, and hence does not use Flash-specific objects or keywords. The classes created for the AMFPHP framework are standard looking PHP classes with a methodTable attribute that won’t interfere if you plan to use these classes for other purposes. Actionscript variables are transferred very naturally as outlined in handling datatypes.

AMFPHP is a real, interoptable Remoting gateway, unlike language-specific solutions like PHPObject. That means that it’s easy to migrate applications that were made for ColdFusion, Java or .NET remoting to the AMFPHP framework: the Actionscript is basically unchanged.

Finally, a distinguishing feature of AMFPHP is the complementary service browser, which allows you to view your service specs using a web browser. The system even generates Actionscript for you, making it much easier to get started if you are a Remoting beginner.

AMFPHP Development Team -
Complete documentation:

Related Flex Tutorials