PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

CHAPTER 20 ■ CONTINUOUS INTEGRATION


Some of those warnings are a little out of date, since my classes use namespaces rather than the
package underscore convention. Nevertheless, I have a successful build. Now to deploy.


$ pear install --force userthing-1.2.1.tgz


install ok: channel://pear.appulsus.com/userthing-1.2.1


So I have a lot of useful tools I can use to monitor my project. Of course, left to myself I’d soon lose
interest in running them. In fact, I’d probably revert to the old idea of an integration phase, and pull out
the tools only when I’m close to a release, by which time their effectiveness as early warning systems will
be irrelevant. What I need is a CI server to run the tools for me.


CruiseControl and phpUnderControl


CruiseControl is a Continuous Integration server written in Java. It was released by ThoughtWorks (the
company that employs Martin Fowler) in 2001. Version 2.0, a complete rewrite was released in late 2002.
According to directives in a configuration file (config.xml) CruiseControl kicks off a build loop for
the projects it manages. For each project this involves any number of steps, which are defined in an Ant
build file (remember, Ant is the original Java tool upon which Phing is based). Once the build has been
run, CruiseControl, again according to configuration, can invoke tools to build reports.
The results of a build are made available in a Web application, which is the public face of
CruiseControl.
We could configure CruiseControl to run any tools we want, and to generate reports for us, after all
CruiseControl is designed to glue any number of test and build systems together. It would take a fair
amount of work though. I’m sure you’d like something off the peg that already integrates some of the
PHP tools you’ve already seen. phpUnderControl provides exactly that functionality. It customizes
CruiseControl so that tools like PHPUnit and CodeSniffer are run, and their reports integrated into the
Web interface.
Before I can use phpUnderControl, though, I must install CruiseControl.


■Note Why CruiseControl? CruiseControl is well established, and it has an excellent pedigree having been


developed by ThoughtWorks. It’s free and open source. Tools that support integration with PHP are under active


development. The fact that many of these are hosted at phpunit.de bodes well for continuing support and


interoperability. There are many CI server solutions out there, however. If you’re looking for a native PHP


implementation, you should definitely take a look at Xinc (http://code.google.com/p/xinc/).


Installing CruiseControl


CruiseControl is a Java system, so you will need to have Java installed. How you go about this will
vary from system to system. On a Fedora distribution you might do something like


yum install java-1.6.0-openjdk-devel


In a Debian system this should do the job
Free download pdf