WebORB for PHP provides a Flex Remoting, Data Management and Flex Messaging implementation. Using WebORB, PHP developers can integrate Flash, Flex, Silverlight and AJAX client applications with objects deployed in PHP applications.
This guide provides an overview of creating a Flex client using Flex Builder and connecting it with a PHP application. The result of the walkthrough is a Flex application communicating with a PHP object exposed through WebORB for PHP.
WebORB for PHP installation has the following directory structure:
|
┬ WEBORB
Installation directory │ ├── index.php ------- management console point of entry │ ├── weborb.php ------- main PHP script - place it into the │ same directory where your compiled SWF │ are located and adjust paths in the │ require_once calls in the file │ ├── /Services ------- contains deployed 'remotable' PHP classes │ ├── /examples ------- contains examples shipped with WebORB │ ├── /Console ------- contains WebORB Management Console │ │ │ ├─ index.php ----- main console page │ │ │ └─ weborb.php ----- remoting entry point for the console │ ├── /weborbassets │ │ │ └─ weborb.swc ----- client-side class library, │ required for messaging apps │ └── /Weborb ------- contains configuration, log and │ WebORB for PHP source code │ ├─ weborb-config.xml ----- contains a reference to the │ /Services folder, as well as other │ important weborb configuration │ └─ /WEB-INF │ └─ /flex │ ├─ remoting-config.xml -- configures Flex destinations ├─ messaging-config.xml -- configures Flex messaging │ destinations └─ services-config.xml -- configures Flex RPC endpoint |
If you are deploying on a Windows computer with IIS, make sure to grant Read/Write permissions to the IUSR_<machinename> account for the /Weborb folder.
You can verify the installation by running WebORB Management Console included with the WebORB distribution. Open localhost/[WEBORB INSTALL PATH]/index.php in a browser. When the console is loaded, you can inspect available PHP remoting services using the Management tab or run the examples included with the product.
To create a Flex Builder project to work with WebORB for PHP, follow the instructions from this article or watch this screencast.
WebORB for PHP product distribution contains a finished Flex application demonstrating Flex to WebORB connectivity and a remoting invocation. Copy and paste the contents of the example.mxml file located at
\Examples\SampleApp\
into the mxml file created in Flex Builder. The code in the application connects to a PHP object and retrieves some basic information about the computer where the object is running.
In order to communicate with a remote PHP object, Flex application uses the RemoteObject API to create a remoting proxy:IMPORTANT: Make sure to locate the directory where Flex Builder copies 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:
VERY IMPORTANT: 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
At this point the Flex client is ready to run. You can use Flex Builder to launch the application.