Invocation of a PHP object using the <mx:RemoteObject> MXML
declaration can be done in just a few simple steps. This
mini tutorial will guide through the setup and
configuration:
Download and install WebORB for PHP (use the
Getting Started guide if you need assistance with
this step).
Deploy the PHP class you will be invoking from Flex into
/app/services folder of your Rails application.
Open /Weborb/WEB-INF/flex/remoting-config.xml in a text editor and add a destination declaring your
PHP class using the following format:
private function faultHandler(event:FaultEvent):void
{
Alert.show(event.fault.faultstring, "Error");
}
Now anywhere in your MXML application you can invoke sayHello using the following line of code:
helloWorldService.sayHello();
Locate
the directory where Flex Builder places the compiled
client application. It is very important to place a copy
of weborb.php into the same directory. weborb.php must
contain the following PHP code:
$m_ORBHttpHandler = new ORBHttpHandler();
$m_ORBHttpHandler->processRequest();
?>
The first line must be
edited to point to the Weborb directory from the
product distribution. For example, look at weborb.php
located in the /Console folder.