Phing - A PHP Build Tool (An Introduction)
-
Upload
michiel-rook -
Category
Technology
-
view
11.963 -
download
2
Transcript of Phing - A PHP Build Tool (An Introduction)
Phing A PHP Build Tool
An Introduction
Michiel Rook
DPC 2011 - Uncon
About me
Michiel Rook
Freelance PHP/Java consultant
Phing project lead
http://nl.linkedin.com/in/michieltcs
@michieltcs
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
Features
Scripting using XML build files
Mostly cross platform
Interface to various popular (PHP) tools
Features
Installation
PEAR installation
$ pear channel-discover pear.phing.info
$ pear install [--alldeps] phing/phing
Optionally install the documentation
$ pear install phing/phingdocs
Why A Build Tool?
Why A Build Tool
Repetitive tasksVersion control
(Unit) Testing
Configuring
Packaging
Uploading
DB changes
...
Why A Build Tool
For developers and deployments
Automate!Easier handover to new team members
Improves quality
Reduces errors
Saves time
Why 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
Why 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
The Basics
Phing uses XML build files
Standard elementsTask: 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
Example Build File
Hello World!
Properties
${version}
## build.propertiesversion=1.0
FileSet
Constructs a group of files to process
Supported by most tasks
FileSet
Selectors allow fine-grained matching on certain attributes
Mappers & Filters
Transform files during copy/move/...
MappersChange filename
FiltersStrip comments
Replace values
Perform XSLT transformation
Translation (i18n)
Mappers & Filters
Testing
Built-in support for PHPUnit / SimpleTest / Xdebug
Various output formats
Testing
Testing
Extending Phing
Numerous possibilitiesTasks
Types
Selectors
Filters
Mappers
Loggers
...
Sample Task
class SampleTask extends Task{ private $var; public function setVar($v) { $this->var = $v; } public function main() { $this->log("value: " . $this->var); }}
Sample Task
Ad Hoc Extension
class FooTest extends Task { private $bar;
function setBar($bar) { $this->bar = $bar; }
function main() { $this->log("In FooTest: " . $this->bar); } } ]]>
More Uses For Phing
Installation
Bootstrap dev. environments
DB migrations
Analyze code
Run (unit) tests
Upgrade server
What's Next For Phing
ImprovementsMore tasks (DocBlox), bug fixes
Test coverage
Cross-platform compatibility
Pain-free installation of dependencies
IDE support
We would love more contributions!
Questions?
http://www.phing.info
http://joind.in/3475
#phing (freenode)
@phingofficial