Deploying an application can be tedious and error-prone. Using Phing’s rich set of tasks, easy extension points and simple XML build files to handle the packaging, deploying and testing of your application can help you save time and increase quality. After this talk you will know how to use Phing and how to tailor it to your specific situation. A number of demonstrations will help illustrate transformation, file synchronization, database migration and other real-world use cases.
1. Deploying PHP applications with Phing
Michiel Rook
PHPNW11 - October 8th, 2011
Deploying PHP applications with Phing – 1 / 37
2. About me
Freelance PHP/Java consultant
Phing project lead
http://www.linkedin.com/in/michieltcs
@michieltcs
Deploying PHP applications with Phing – 2 / 37
3. About Phing
PHing Is Not GNU make; it’s a PHP project build system or build tool based on
Apache Ant.
Originally developed by Binarycloud
Ported to PHP5 by Hans Lellelid
I joined in 2005
Deploying PHP applications with Phing – 3 / 37
4. Features
Scripting using XML build files
Mostly cross-platform
Interface to various popular (PHP) tools
Deploying PHP applications with Phing – 4 / 37
7. Why Use A Build Tool?
Deploying PHP applications with Phing – 7 / 37
8. Why Use A Build Tool
Repetitive tasks
Version control
(Unit) Testing
Configuring
Packaging
Uploading
DB changes
...
Deploying PHP applications with Phing – 8 / 37
9. Why Use A Build Tool
For developers and administrators
Automate!
Easier handover to new team members
Improves quality
Reduces errors
Saves time
Deploying PHP applications with Phing – 9 / 37
10. Why Use Phing
Rich set of tasks
Integration with PHP specific tools
Allows you to stay in the PHP infrastructure
Easy to extend
Embed PHP code directly in the build file
Deploying PHP applications with Phing – 10 / 37
11. Why Use Phing
Rich set of tasks
Integration with PHP specific tools
Allows you to stay in the PHP infrastructure
Easy to extend
Embed PHP code directly in the build file
... in the end, the choice is yours
Deploying PHP applications with Phing – 10 / 37
12. The Basics
Deploying PHP applications with Phing – 11 / 37
13. Build Files
Phing uses XML build files
Contain standard elements
Task: code that performs a specific function (svn checkout, mkdir, etc.)
Target: groups of tasks, can optionally depend on other targets
Project: root node, contains multiple targets
Deploying PHP applications with Phing – 12 / 37
21. Testing
Built-in support for PHPUnit / SimpleTest
Code coverage through XDebug
Various output formats
Deploying PHP applications with Phing – 20 / 37
24. Database Migration
DbDeploy
Set of delta files (SQL)
Tracks current version in changelog table
Generates do & undo scripts
Deploying PHP applications with Phing – 23 / 37
28. Packaging
Then build a TAR
<tar compression="gzip" destFile="package.tgz"
basedir="build"/>
... or ZIP
<zip destfile="htmlfiles.zip">
<fileset dir=".">
<include name="**/*.html"/>
</fileset>
</zip>
Deploying PHP applications with Phing – 27 / 37
36. More Uses For Phing
Installations and upgrades
Bootstrapping development environments
Code analysis
Version control (SVN / GIT)
Code encryption / encoding
Deploying PHP applications with Phing – 35 / 37
37. More Uses For Phing
Installations and upgrades
Bootstrapping development environments
Code analysis
Version control (SVN / GIT)
Code encryption / encoding
Check the documentation!
Deploying PHP applications with Phing – 35 / 37
38. The Future
Improvements
Better performance
Increased test coverage
Cross-platform compatibility
Pain-free installation of dependencies (PHAR?)
More documentation
IDE support
Moving to GitHub
We would love (more) contributions!
Deploying PHP applications with Phing – 36 / 37