2. Phing for power users
About me
Stephan Hochdörfer
Head of IT at bitExpert AG, Germany
enjoying PHP since 1999
S.Hochdoerfer@bitExpert.de
@shochdoerfer
39. Enforce Internal Targets – The solution
Phing for power users
$> ./vendor/bin/phing -f build.xml -init
Unknown argument: -init
phing [options] [target [target2 [target3] ...]]
Options:
-h -help print this message
-l -list list available targets
-v -version print the version information
-q -quiet be extra quiet
-verbose be extra verbose
-debug print debugging information
Report bugs to <dev@phing.tigris.org>
63. build.properties example
Phing for power users
phpunit.path=vendor/bin/phpunit
phpunit.junit.log=build/logs/junit.xml
phpunit.coverage.clover=build/logs/clover.xml
phpunit.coverage.html=build/coverage
phpcs.path=vendor/bin/phpcs
phpcs.log=build/logs/checkstyle.xml
sencha.senchaCmd=/user/local/lib/sencha/sencha
sencha.jsb3File=app.jsb3
70. <?xml version="1.0"?>
<project name="myproject" default="app:run">
<!--
The following target namespaces exist:
db:* - Database specific targets
app:* - Application specific tasks
ci:* - CI server specific tasks
-->
<import file="build/build.db.xml" />
<import file="build/build.app.xml" />
<import file="build/build.ci.xml" />
</project>
Imports for Targets can help structuring
Phing for power users
71. <?xml version="1.0"?>
<project name="myproject" default="app:run">
<!--
The following target namespaces exist:
lib1:* - Targets imported from lib1
lib2:* - Targets imported from lib2
app:* - Local application targets
-->
<import file="vendor/vendor1/lib1/build/build.xml" />
<import file="vendor/vendor2/lib2/build/build.xml" />
<import file="build/build.app.xml" />
</project>
Import Targets: Composer packages
Phing for power users
72. Import Targets: Path handling
Phing for power users
Be aware that imports behave
like include in PHP!
73. <?xml version="1.0"?>
<project name="myproject" default="lib1:run">
<!--
The following target namespaces exist:
lib1:* - Targets imported from lib1
-->
<import file="vendor/lib1/build/build.xml" />
</project>
Import Targets: Path handling
Phing for power users
build.xml
80. <?xml version="1.0"?>
<project name="myproject" default="app:create-cache">
<target name="app:clean-cache"
description="Removes all cache files.">
</target>
<target name="app:create-cache"
description="Builds the cache files from the
xml configuration.">
</target>
</project>
Adding meaningful descriptions
Phing for power users
81. $> phing -l
Buildfile: /tmp/myproject/build.xml
Default target:
-----------------------------------------------------
app:create-cache Builds the cache files from the xml
configuration.
Main targets:
------------------------------------------------------
app:clean-cache Removes all cache files.
app:create-cache Builds the cache files from the xml
configuration.
Adding meaningful descriptions
Phing for power users
82. Prompt user for input
Phing for power users
<?xml version="1.0"?>
<project name="myproject" default="run">
<target name="run">
<!-- tag the database -->
<input
propertyname="tag"
defaultValue="mytag">Tag to create?</input>
<liquibase-tag
tag="${tag}"
jar="/opt/liquibase/liquibase.jar"
classpathref="/opt/liquibase/lib/mysql.jar"
changelogFile="${project.basedir}/diff.xml"
username="liquibase"
password="liquibase"
url="jdbc:mysql://localhost/myproject"/>
</target>
</project>