It is time to get our hands dirty and start pulling the pieces of code together. First, get the latest SabreAMF package (linked to in the Requirements section) and install it. Also install PHP 5 and PEAR on your web server. With the PEAR utility in your path, open up a command prompt and run the following installation command:
pear install http://www.rooftopsolutions.nl/code/SabreAMF/downloads/SabreAMF-latest.tgz
Note: For more detailed installation instructions, go to osflash.org/sabreamf and click the Installation Instructions section.
SabreAMF provides a base set of classes to create specific custom gateways to support different types of AMF clients. There is a Flex-specific PHP gateway and callback server in the source code for this article (available in the Requirements section on page 1) that provides support for the Flex 2 RemoteObject component. You can find the Flex-specific PHP gateway source code and sample PHP services source code in the PHP RIA SDK by Adobe. Adobe's open source and web development evangelist, Mike Potter, started the package to help PHP developers learn how to build solutions with Adobe RIA technologies.
Note: The unofficial PHP RIA SDK by Adobe code base provides examples for showing how to use PHP with Flex and the Adobe Spry Ajax framework. You can find more PHP and Flex examples by downloading the full PHP RIA SDK by Adobe.
You can create the PHP sample files and the Flex project by following along with the article, but you will need to download and extract the PHP gateway source code from the sample code package. The following steps walk you through the configuration stage:
Navigate to your PHP web root and create the following folders:
Note: These folders now become the home for the Flex-specific PHP gateway and the PHP remote objects.
Locate the gateway.php and flex-gateway folder in the source code package and copy both into the newly created sabreamf folder.
Note: You can also copy the folder named sabreamf located in the downloaded source code into your web root.
Create a new Basic Flex Builder project and import or copy the files above into the project.
Note: The article will walk you through the source of services-config.xml, simple_sabreamf.mxml, and UserVO.as. Remember to create the folder com/renaun/samples/vo/ for the UserVO.as file.

Figure 2. Setting -services argument in the project's Properties dialog box
The services-config.xml file specifies to the Flex application where to look for the gateway and which adapter to use. Here is the contents of the services-config.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service id="sabreamf-flashremoting-service"
class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">
<destination id="SabreAMF">
<channels>
<channel ref="my-sabreamf"/>
</channels>
<properties>
<source>*</source>
</properties>
</destination>
</service>
</services>
<channels>
<channel-definition id="my-sabreamf" class="mx.messaging.channels.AMFChannel">
<endpoint uri="http://{server.name}:{server.port}{context.root}/sabreamf/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
</services-config>
The services and channels tags are used to define adapters and endpoints/gateways. The destination tag inside a services tag defines client-side RemoteObject components to source remote objects.
The sources tag found in this configuration has a value of *, which means the source value must be defined in the RemoteObject component. The destination is linked to a channel called my-sabreamf.
The channels tags define endpoints that specify to the gateway. The gateways are the actual code that consume and respond to remote service calls. You will see that the channels tag specifies an endpoint to the Flex-specific SabreAMF PHP gateway located here:
http://{server.name}:{server.port}{context.root}/sabreamf/gateway.php