The Foobar
project installs some PHP files from a source location
to a target location, creates an archive of this files and provides an optional clean-up
of the build tree:
<?xml version="1.0" encoding="UTF-8"?> <project name="FooBar" default="dist"> <!-- ============================================ --> <!-- Target: prepare --> <!-- ============================================ --> <target name="prepare"> <echo msg="Making directory ./build" /> <mkdir dir="./build" /> </target> <!-- ============================================ --> <!-- Target: build --> <!-- ============================================ --> <target name="build" depends="prepare"> <echo msg="Copying files to build directory..." /> <echo msg="Copying ./about.php to ./build directory..." /> <copy file="./about.php" tofile="./build/about.php" /> <echo msg="Copying ./browsers.php to ./build directory..." /> <copy file="./browsers.php" tofile="./build/browsers.php" /> <echo msg="Copying ./contact.php to ./build directory..." /> <copy file="./contact.php" tofile="./build/contact.php" /> </target> <!-- ============================================ --> <!-- (DEFAULT) Target: dist --> <!-- ============================================ --> <target name="dist" depends="build"> <echo msg="Creating archive..." /> <tar destfile="./build/build.tar.gz" compression="gzip"> <fileset dir="./build"> <include name="*" /> </fileset> </tar> <echo msg="Files copied and compressed in build directory OK!" /> </target> </project>
A phing build file is normally given the name build.xml
which is
the default file name that the Phing executable will look for if no other file name is
specified.
To run the above build file and execute the default target (assuming it is stored in
the current directory with the default name) is only a matter of calling: $
phing
This will then execute the dist
target. While executing the build
file each task performed will print some information on what actions and what files have
been affected.
To run any of the other target is only a matter of providing the name of the target on
the command line. So for example to run the build
target one would
have to execute $ phing build
It is also possible to specify a number of additional command line arguments as described in Fact Sheet