Using the PHP Toolkit with ADO.NET Data Services
- Setup PHP on your windows machine
- Setup the PHP Toolkit
- Setting up the PHP samples on IIS
- Running the sample ADO.NET Data Services
- PHP Sample Applications Walkthrough
Setup PHP on your windows machine
The following steps show you how to setup your windows machine to host PHP applications.
We will be talking about hosting the only supported ( by MS Support ) PHP CGI application on IIS .
- If you don’t find the php.ini-recommended file , then rename the php.ini-development file from your PHP folder.
- Once you are setup , if you get a HTTP 500 internal server error when browsing to the Php.ini file ,
then you need setup your timezone in the PHP.ini file .
- To do this , find the line in the php.ini file “date.timezone” .
- If it has a semi-colon before it , remove it .
- Set the date.timezone’s value to be a valid value from this list : List of Supported Timezones
In my php.ini , I have set the value to be date.timezone = "America/Los_Angeles"
Setup the PHP Toolkit
Follow the instructions on the codeplex site to setup your machine.
Installation and Configuration
Setting up the PHP samples on IIS
I have copied the phpsamples folder from the downloaded phpdataservices1.0 folder
into the %SystemDrive%\inetpub\wwwroot folder.This is just so that I dont need to configure any permissions
for the IIS accounts.
Open the IIS manager by running “INETMGR” from the “run” prompt on the start menu
This sets up the PHP applications that access the ADO.NET Data Service,
We still need to setup the actual Data Services that the PHP Samples access.
Running the sample ADO.NET Data Services
Find the ADODotNetDataServices folder in the PHPDataServices1.0 download.
This should be under the “samples” directory.
Setup the Databases required for the project to run
1) Unzip the zipped database files from the
2) Open up SQL management studio and Connect to your Database server
3) Right–click the databases node and select “Attach…”
4) In the “Attach Database” dialog , press “Add” and select the unzipped “VideoGameStore_Data.mdf” file.
You will notice that once you select the MDF file , the dialog will complain about a missing .ldf file.
5) This is a routine warning , select the ldf file row in the dialog and press “Remove”
For the other database Northwind, you can use the sample database that are available from Download.Microsoft.com
Here’s a link to download the Northwind sample database : Northwind and pubs Sample Databases for SQL Server 2000
Installation should be straight-forward as it comes with an MSI that is supposed to setup the database for you.
Disclaimer : I already had a copy of the Northwind database on my machine and didn’t use the installer above.
Once you have your databases setup , modify the respective connection strings web.config file from the ADODotNetDataServices project.
<connectionStrings> <add name="NorthwindEntities" connectionString="metadata=res://*/NorthwindModel.csdl|res://*/NorthwindModel.ssdl|res://*/NorthwindModel.msl; provider=System.Data.SqlClient; provider connection string="YOURCONNECTIONSTRINGHERE"" providerName="System.Data.EntityClient" /> <add name="VideoGameStoreEntities" connectionString="metadata=res://*/VideoGameStoreModel.csdl|res://*/VideoGameStoreModel.ssdl|res://*/VideoGameStoreModel.msl; provider=System.Data.SqlClient; provider connection string="YOURCONNECTIONSTRINGHERE & quot;" providerName="System.Data.EntityClient" /> </connectionStrings>
Once you have the database and the Data Service setup, then configure the project to only run on the URL that the PHP Samples expect to find the Data Service on.
To do this :
In Visual Studio,Go to the properties of the Project.
Click on the “Web” Tab in the left-hand pane.
Under the “Servers” section , Select the “Specific Port” option and enter “8080” for the port number.
Now, run the project in Visual studio and launch the PHP samples by browsing to the Index.php page
in the PHPSamples virtual directory.
PHP Sample Applications Walkthrough
You should see this as the startup page when you run the PHP Samples
Demo tab contents
Select the ADO.NET Data Services Editor Sample to see some pure PHP awesomeness
Here’s an editor page for the Customers Entity Set:
See that little text box over there ?
Yeah , it allows me to enter the Astoria URI operators like top , skip , filter to filter the rows bound to the grid below.
The gird is editable too , Clicking on the “Detail” link in the first column of the grid brings up an editor for the customers
entity that was selected.
So , there you have it , instructions to setup the samples and some tours of the sample applications.
Since I know next to nothing about PHP , I have a few questions for our PHP-Savvy users.
- Which application framework(s) do you use to build PHP applications? I know about CAKE and ZEND , any others?
- Do you use a specific Validation framework or do you use the one that came with the application framework?