Lightweight Continuous Integration for PHP

Posted in PHP, Programming and Testing on Thursday, the 20th of August, 2009.

This post describes a simple, lightweight strategy for implementing Continuous Integration on PHP-based software projects. This approach happens to use Subversion for version control, PHPUnit for unit testing, and Phing to automate the processes involved, but hopefully the principles are generally applicable.

The post won't strive to be exhaustive or encyclopaedic, rather it will present a simple proof-of-concept and a brief overview of the tools that are available to PHP developers. But first some background...

Comments

Posted by Ciaran McNulty on Thursday, the 20th of August, 2009.

Very interesting stuff!

So much of the CI literature seems to end up being 'how to set up CruiseControl' that it's refreshing to see how it's possible to 'roll your own'.

A third option aside from cron or an svn hook would be to run the CI as a daemon - I suspect this is what apps like CruiseControl effectively do.

Posted by Russell on Friday, the 21st of August, 2009.

We use CruiseControl and it runs everytime something is commited into svn. We have no issues with instances running concurrently as CruiseControl queues them up. CruiseControl can also be set up to give a grace period of, say, 30 secs so that it doesn't run on 'atomic' commits.

I would prefer this to your alternative of running the process periodically. I could see this leading to problems particularly in a larger team or a very active project. I suppose however that you could adjust the frequency of the cron based on the size / activity of the team.

Your assertion that you "don't believe that anyone can call themselves a professional developer unless they're delivering unit tests" is possibly a little bold. We have several very good developers not writing any tests based on a decision we made to not enforce test driven development on some of our legacy code. Rightly or wrongly you may argue!

Either way this is a particularly good post even by your own high standards and an excellent guide to getting CI up and running.

Posted by Simon Harris on Friday, the 21st of August, 2009.

Thanks, gents.

I should stress that I'm not questioning the validity of CruiseControl (or phpUnderControl, they're essentially the same product) and their daemons and associated magic, I'm just highlighting an alternative route for those who don't have the time/inclination/management buy-in to make a good fist of xControl at the present time, which I suspect is quite a lot of people.

Regarding unit tests, it's something I'm not ashamed to have very strong feelings about. That said, I may reword have reworded that section so as not to distract from the matter at hand.

For what it's worth, I think my gripe is with a wider issue, in that professional standards in software development are...well, there aren't any. So developers are quite used to "getting away" with very disappointing practices, and nobody really notices. In a lot of shops, if you churn out epic amounts of code, you're a hero developer, right? Perhaps that's a rant best saved for a future post, all the same.

Posted by Andrew Tulloch on Saturday, the 29th of August, 2009.

Been using Hudson (http://hudson.dev.java.net/) at work for several months now, primarily with maven based java projects, but it's extensible with plugins (including one for phing). Very easy to setup and once running I all web interface configurable. Can either poll svn repos or have commit hooks on the repos to inform hudson of changes. I'd recommend giving it a go.

Posted by Luka on Sunday, the 11th of December, 2011.

Incredibly concise article...
I am new to CI (even though I am not new to PHP OOP, design patterns and best principles) It was really bumpy voyage understanding the CI concept and need for it when I first entered into one project based on JEE/Struts, Maven and SVN...
I got it now together with the point of writing unit tests and running them on regular bases with CI tools and I'll be more than happy to try to integrate it into my future PHP development...
Thanks

Enter your comment: