(^116) CHAPTER 8 ■ TESTING, DEPLOYMENT, AND CONTINUOUS INTEGRATION
Writing a Phing Deployment Script.
Phing uses a simple XML configuration file format, which takes information about the project
and allows you to define groups of actions, called targets. As an example, you will create a basic
Phing deployment script that defines four targets:
- get will export the latest files from your Subversion repository.
- test will execute your unit tests.
- try will copy files to a nonproduction web site for functional testing.
- deploy will copy the files to a production web site.
By default, the phing binary looks for an XML file called build.xml when it is called on the
command line. Listing 8-6 shows a simple build.xml file.
Listing 8-6. A Phing Build File (build.xml)
<?xml version="1.0"?>
<project name="MyFirstPhingProject" basedir="." default="try">
<fileset dir="./code" id="codefiles">
<include name="**" />
</fileset>
<target name="get">
<svnupdate
svnpath="file:///usr/local/svn/myfirstrepo"
todir="."
/>
</target>
<target name="test" depends="get">
<phpunit haltonfailure="true" printsummary="true">
<batchtest>
<fileset dir="./tests">
<include name="*Test.php" />
</fileset>
</batchtest>
</phpunit>
</target>
<target name="try" depends="test">
<copy
todir="/usr/local/www/beta.example.com/document_root"
overwrite="true"
McArthur_819-9C08.fm Page 116 Friday, February 22, 2008 9:06 AM