Introduction
This is the seventh article of a series of blog post called the WIMPinator Chronicles that describe how to setup a PHP development environment for Windows 7 and IIS 7.5.
So far we covered how to install a Wordpress blog and all its dependencies using the WPI (Web Platform Installer). Then we added additional features and extensions to the PHP deployment on Windows for IIS. I explained how to get PEAR setup and how to download and deploy the PHPUnit unit testing framework using PEAR. In the next two posts I described how to install Eclipse PDT and make it work with Subversion source control using Subclipse. In the most recent post I explained how to create an IIS 7.5 Fast CGI web site from scratch.
This tutorial covers how to use ANT build tasks to deploy your PHP project from Eclipse to your IIS test server using custom build steps.
The Series
- Getting a Wordpress blog installed in a jiffy on Windows 7 using the Web Platform Installer
- Adding additional features to PHP
- Installing PEAR and PHPUnit
- Installing Eclipse PDT
- Configuring Eclipse PDT to work with Subversion source control
- Creating a new IIS 7.5 fast CGI web site
- Configuring Eclipse to work with Ant build tasks
- Setting up XDebug with Eclipse and IIS 7.5
- Setting up the Zend Debugger with Eclipse and IIS 7.5
- Configuring Ruby and Watir
- Moving a Wordpress blog from GoDaddy shared hosting to my local debugging system.
- NEW: Setting up the CodeIgnitor MVC framework with PDT and IIS 7.5
- NEW: Configuring IIS 7.5 Rewrite rules to exclude index.php from the URL
- NEW: Configuring SSL on IIS 7.5
- NEW: Writing unit tests with PHP Unit
- NEW: Writing web UI tests with Watir
References
While searching the interweb about this topic I found the following tutorial:
http://individual.utoronto.ca/kia/
Add Ant to Eclipse PDT
To move the php and html files to your test and production IIS web site from Eclipse you would use Ant build tasks. Unfortunately Ant is not installed by default in Eclipse PDT. But it comes with the standard version of Eclipse. In fact it is part of the Java development plug-in.
To install the Java plug-in go to the Eclipse menu Help\Install New Software.
Figure 1: Go to the Eclipse Help\Install Software Menu
Select Galileo from the “Work with” drop down list.
Figure 2: Choose Galileo
Expand the Programming Languages node and select Eclipse Java Development Tools.
Figure 3: Select the Eclipse Java Development Tools
Click Next to get to the Install Details dialog.
Figure 4: Click next to confirm the Install Details
Accept the Eula.
Figure 5: Accept the license agreement
The download and installation starts after you click the Finish button.
Figure 6: Installing the Java development plug-in
At the end of the installation you might be asked to restart Eclipse. Click No and then restart Eclipse manually.
Figure 7: Click No and restart Eclipse manually
Create your first Ant task
First create a new XML file and name it for example MoveToIISTask.xml.
Figure 8: Create new XML file
Right click on new xml file and select open with other…. This will open the Editor Selection dialog.
Figure 9: Open the XML file and select Other…
In the Edit Selection dialog select Ant Editor.
Figure 10: Select the Ant Editor
Create a copy task. Use the Ant manual for help. Search for File Tasks.
Figure 11: Screenshot of an Ant copy task
You could copy and past the following snippet and modify it for your needs:
<?xml version="1.0" encoding="UTF-8"?>
<project name="CIM225" default="CopySite" basedir=".">
<property name="IIS Virtual Directory" value="c:/inetpub/wwwroot/cim225/"/>
<target name="CopySite">
<echo>${IIS Virtual Directory}</echo>
<copy todir= "${IIS Virtual Directory}">
<fileset dir=".">
<include name="**/*.php"/>
<include name="**/*.html"/>
<include name="**/*.txt"/>
<include name="**/*.css"/>
<include name="**/*.js"/>
<include name="**/*.gif"/>
<include name="**/fruitdbbackup.sql"/>
<include name="**/*.zip"/>
</fileset>
</copy>
</target>
</project>
Hooking up the build task script with an Eclipse Builder
Now select your project and press Alt + Enter (Right mouse click “Properties”).
Figure 12: Go to the project properties
Go to the Builders node in the Properties dialog.
Figure 13: Select the Builders node
Click the New button to create a new Builder and select Ant Builder from the Choose configuration type dialog.

Figure 14: Choose the Ant Builder
Give the Builder a name in the Edit Configuration dialog.
Figure 15: Name your Builder
Now select a Build file using the Browse Workspace button. Choose the MoveTOIISTask.xml file in the Choose Location dialog.
Figure 16: Select the Ant build task xml file
Also select a Base Directory using the respective Browse Workspace button.
Figure 17: Use the Browse Workspace button to select the project folder as Base Directory
The Builder configuration is now complete and the finished dialog should look like this.
Figure 18: Build task is now complete
Closing this dialog by clicking OK will result in the following list of Builders.
Figure 19: New Builder has been added to list
Executing the new build task
In order to execute this Ant task, select your project and go to Project Build All (Ctrl+B).
Figure 20: Start a build with Ctrl+B
The build will now copy the selected files to the IIS application folder and the result is displayed in the Eclipse console window.
Figure 21: Build (copy files) completes successfully
Note: Make sure that you have sufficient permissions to access the IIS7 virtual directory (Inetpub\wwwroot\cim225). Otherwise you will get an access violation error during the copy process.
Note: If nothing in the project has changed since the last build, the ant task will not be executed.
Ausblick
This concludes this part of the WIMPinator tutorial. The build steps can still be improved. Here are some tasks that I’d like to add:
- Create a debug, stage and production deployment step
- Launch web site in default browser
- Execute PHPUnit unit tests
- Execute Watir (Ruby) web ui tests
In the next two blog posts I am going to write about how to setup the Zend and XDebug extension to use with Eclipse.
Stay tuned!