PHP Toolkit for ADO.NET Data Services – erasing bounds of technologies: PHP + .NET
Microsoft Interoperability team announced an release of the new project which is the bridge between PHP and.NET and erases bounds of technologies even more. This project allows developers on PHP even more easier to access and use all power of .NET services which based on ADO.NET Data Services.
From the point of view of working out the scheme looks classically enough. By working out it is necessary to use utility PHPDataSvcUtil which is in PHP Toolkit for ADO.NET Data Services. This utility will generate proxies-classes on PHP using metadata which are accessible to service on the basis of ADO.NET Data Services. After that on PHP also it will be necessary to connect libraries PHP Toolkit to the project for ADO.NET Data Services. Further, after all these simple actions it will be possible to use all power of ADO.NET Data Services platform within of appendices on PHP in more convenient way.
Let's look how the code on platform PHP for executing of queries to ADO.NET Data Services will look. Firstly it is necessary to connect a file with proxies-classes, which generated by PHPDataSvcUtil utility:
<?PHP
require_once 'NorthwindClient.php';
define("SERVICE_URI", "http://localhost:8080/Northwind.svc");
?>
After that it is possible to create the objects of a class which implements the logic of the client and to carry out queries to remote service. Unfortunately, here we cannot take advantage of LINQ syntax for construction of queries to service. Therefore it is necessary to write query manually in the form of URI.
<?PHP
$client = new NorthwindEntities(SERVICE_URI);
$query = $client->ExecuteQuery("Customers?\$filter=Country eq 'UK'");
?>
Now, after successful designing of query it is possible to access for a data and to show result to the user:
<?PHP
foreach($query as $customer)
{
echo "<p>";
echo $customer->CustomerID;
echo "<br/>";
echo $customer->CompanyName;
echo "</p>";
}
?>
Here it is well visible, that we access to strongly typified objects, and result we receive in the form of objective collections. Such way is very similar to how we work with services of ADO.NET Data Services within the .NET-client. These of entity classes also have been generated by utility PHPDataSvcUtil.
Pablo Castro (program manager, ADO.NET Data Services) and Claudio Caldato (program manager, interoperability, techincal strategy team) have made the small review of this library on Channel 9 in which they tell more details
At last that the project is the project with an open source code is very interesting and is accessible on CodePlex. Besides, the project is developed by company Persistent Systems, but fund by Microsoft.
Links:
- The announcement in a blog of Astoria team - http://blogs.msdn.com/astoriateam/archive/2009/08/21/announcing-the-php-toolkit-for-ado-net-data-services.aspx
- The description in a blog of Interoperability team - http://blogs.msdn.com/interoperability/archive/2009/08/21/a-new-bridge-for-php-developers-to-net-through-rest-php-toolkit-for-ado-net-data-services.aspx
- Channel9 - http://channel9.msdn.com/posts/jccim/Consuming-data-over-the-web-between-PHP-and-NET-with-REST-and-ADONET-Data-Services/
- The project at CodePlex - http://phpdataservices.codeplex.com/