WebORB for PHP supports invocations of PHP classes from Silverlight client applications. Using WebORB, Silverlight developers can easily integrate client applications with PHP backend without all the complexity associated with the traditional methods Silverlight relies on.
This guide provides an overview of creating a Silverlight project connecting it with a PHP class using WebORB. The result of the walkthrough is a Silverlight application communicating with a PHP object which runs a database query, returns a result subsequently rendered in Silverlight data grid component.
Required software:
|
┬ 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 │ │ │ └─ /silverlight │ │ │ └─ WeborbClient.dll ---- Silverlight client component │ └── /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 |
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 services using the Management tab or run the examples included with the product.
WebORB for PHP includes several PHP classes pre-deployed for remote access. To make a PHP class available for remote access it must be deployed into the /services folder from the WebORB product distribution. You can see all deployed classes using the WebORB Management Console. To launch the console open index.php from the root of the WebORB installation folder using the following URL: localhost/WEBORB-HOME-PATH/index.php
Click the Management tab, all deployed services will show up in the service browser in the Services sub-tab. In the service browser click Weborb > Examples and select CustomersDataService as shown below:

The code runs a query against a MySQL database. Before running the code, the database can be created with a SQL script (northwind.sql) located in the [WEBORB-HOME]/Services/Weborb/tests directory. Run the script and continue below.
Back in the server browser tree view select the getCustomers node which represents the method in the CustomersDataService class and click the Invoke button to invoke the method. You should see the result of the method invocation as shown below:

The object displayed in console is the result of the actual PHP method invocation. Expand one of the array items. The structure of individual record in the response should be as shown below:

The response is structured as an array of objects. Each object represents a row in the query result. Object field names correspond to the columns. It is important to know the structure of the response, but it will be more apparent when we develop the client-side code.
The instructions below will guide you through the process of creating and running a weborb-remoting-enabled Silverlight application. The application invokes a method on a PHP class which runs a database query and returns a result.
Using Visual Studio 2008 create a "Silverlight Application" project. This should be a very straight-forward task if you are familiar with Visual Studio 2008. If not, from the main menu select File > New > Project. Assuming you develop with C#, select "Silverlight" under Visual C# in the Project types tree. Enter a name for you project (this guide uses the Silverlight2PHP name as shown below). Click OK to create the project

The next screen provides a choice of either creating a web application to host the Silverlight client or just creating an HTML page for the client which would need to be deployed to a web server. Since you are working with PHP which is already running in a web server, it is recommended to select an option to generate an HTML page. However, that choice also requires that the page is copied to the web server running your PHP script. Make a selection as shown below and click OK:

Select and right-click "References" in the Solution Explorer panel. Then click "Add Reference..." as shown below:

Using the Browse tab navigate to the WebORB for PHP installation and select WeborbClient.dll from the [WEBORB-PATH]\weborbassets\silverlight folder as shown below:

Click OK to add the reference.
Back in the XAML editor right click anywhere in the XAML markup and select "View Code" as shown below:

Save the files and compile the project by pressing F6 or Shift+F6.
Once the project is compiled, deploy the HTML page and the XAP file (Silverlight2PHP.html and Silverlight2PHP.xap if you followed this guide) into the WebORB home directory and run the Silverlight client using the following URL: host/WEBORB-HOME-PATH/Silverlight2PHP.html