Getting WebORB for PHP Working

Posted on September 6, 2006 | 1 comment

The midnightcoders have provided a nice package to use RPC services with Flex and PHP. The newly release WebORB for PHP is an exciting project. For there site:

WebORB for PHP is server-side technology enabling connectivity between Flex and Flash Remoting clients and PHP applications. WebORB for PHP can be installed into any PHP5 application to expose PHP classes as remote services. The product provides a complete implementation of the Adobe’s AMF0 and AMF3 messaging protocols and thus supports any Flash Remoting or Flex client.

Although this release only supports the RPC featureset of Flex Data Services it is planned for future FDS features. Their documentation and Quick Start guide are top notch and should be easy to follow. They use a deployment folder structure of “Weborb\WEB-INF\flex\” making it easy to use the New Project Wizards in Flex Builder to make FDS or ColdFusion connectivity projects.

Configuration

Now I usually like to take these projects and apply my standard Flex, AMF, and PHP example. This is where I ran into problems. The configuration files are setup disctintly like FDS. I tend to follow the ColdFusion connectivity default configuration files and setup one Destination tag with a <source>*</source> attribute. The * attribute value is not support in the current WebORB for PHP. You need to define the specific source for each destination tag in the services-config.xml (actually in the remoting-config.xml that is included in the services-config.xml).

I added the following to the remoting-config.xml

<destination id=”LoginServiceDestination”>
<properties>
<source>com.renaun.samples.login.services.Login</source>
</properties>
</destination>

The example Flex application is from my example code used in the RemoteObjectAMF0 and my SabreAMF example. You can get the my example code here.

Object Type Mapping

Object typing is a very important feature when working with RemoteObjects and Flash Remoting. FDS and ColdFusion connectivity have built in mechanisms that handle object typing for you. But other packages like SabreAMF, AMFPHP or OpenAMF you need to set the mapping manually. This is where WebORB for PHP uses PHP5 features to make object typing automatic, no manual attributes, method tables, or class mapping functions.

The hiccup was that the object typing didn’t work quite right. The example code provided by WebORB for PHP and my custom BookVO example had an extra “.htdocs.Services.” attached to the class type. I tracked down this issue to Util/TypeLoader.php class in the getFullClassName method. You get to set your services path in the Weborb/weborb-config.xml (default is <weborb servicePath=”../Services”>). The fix to get the correct object is to add “$servicePath = realpath( $servicePath );” in the getFullClassName method right after “$servicePath = $config->getServicePath();”.

Conclusion

Overall WebORB for PHP has great potential. The project is backed by a group that create many great products for Ajax, Flash Remoting and Flex on many different platforms. We are lucky to have them provide this project as open source. I am particularly interested in the further development of FDS polling and data management features.

  • http://www.madeinflex.com Carlos Rovira

    I’m amazed that the project was released as open source, great movement for the community. :)