Magudia.com Blog

Posts Tagged ‘agile’

Agile and PHP

Thursday, February 7th, 2008

So since my last post I’ve actually started to write my SimpleStorageService project and as I’m an agile developer I decided to write the project with the agile skills I’ve picked up over the last few years with Java, .net, scrum-master training et al and check out how easy it actually is to ‘do agile’ with PHP.

So…. where should I begin….

Unit Testing (Test Driven Development):

Firstly PHP has had unit testing for quite some time with PHPUnit; this is something which after using unit testing in Java and C# was actually quite straight forward and although there are other testing frameworks like SimpleTest I decided to go with PHPUnit as it seems more comprehensive; Although I found that SimpleTest has a better mocking implementation than PHPUnit, but for now I’m sticking with PHPUnit.

Also PHPUnit can integrate with Selenium and has a partial implementation of DbUnit, but that’s not complete yet - hopefully this will be complete by PHPUnit 4

Continuous Integration:

Now I didn’t think PHP had anything like this, so when I was looking into testing I found the phpUnderControl project which literally knocked my coding socks off as it’s a PHP wrapper for cruiseControl, but with a cool interface and extra PHP goodies on project code metrics, a Java like checkStyle which defaults to the PEAR coding standard and generating phpDoc as well as the normal cruiseControl stuff.

I was so impressed by this project that at the time (early January) I set it up on my macmini although I did have to use macports to replace the crippled default build of PHP that is bundled with OS X (please fix this Apple!). I initially installed version 0.20 of phpUnderControl, but I’m currently upgrading my install to the recently released version 0.30 which has a neat javascript metrics view - which is nice

Finally phpUnderControl neatly integrates with PHPUnit, which another reason why I’m using this and the project is now hosted alongside PHPUnit, so I hope to see more integration between the projects in the future.

Integrated Development Environment:

Allow this is by all means not needed to practise Agile, but a good IDE helps you write better code faster. I used to use DreamWeaver for all my PHP web development work, but as my SimpleStorageService is by definition a service project I didn’t need any HTML editing functionality. Anyway here was my IDE shortlist:

Ignoring DreamWeaver and TextPad as being out of date and inappropriate for the project I began with Eclipse (with PDT), but I quickly found several problems with this mainly SVN integration amongst other things. Then I gave Aptana a go which was beta at the time and did fix my SVN issues, but in the final version this was removed from the free edition (grrr!). So just when I thought that PHP didn’t have a good IDE literally stumbledupon Zend Studio Neon which ticked nearly every box I wanted from a IDE for PHP … PHPUnit, phpDoc, SVN, code coverage, code formatting, real time error checking, intellisense and much much more. The downsides are a bug where it doesn’t understand the PDO class when unit-testing (well it is beta!) and the final version isn’t free, so I’m using a time trial version which runs out in just over two weeks. Anyone want to buy me a copy ;-)

Source Control:

It still surprises me how many people don’t use or even understand the point of source-control, but I’ve been a big user for many years. Firstly with CVS and then once Subversion (SVN) was more stable I moved to that and didn’t look back. I know there are many other choices here, but as SVN is integrated into phpUnderControl and Zend Studio it was simply a no brainer. My DreamHost account includes SVN so all my code can be committed ‘off site’ and I can create an abstraction between my IDE and continuous integration environment.

Conclusion:

The state of Agile in PHP is good and much much better than it was even six months ago. I think once PHPUnit 4 is released, phpUnderControl reaches stablity and Eclipse with PDT catches up with Zend Studio (add unit testing, svn projects) then Agile in PHP should be excellent and easy to accomplish. One thing I haven’t looked at is if PHP has any good scrum management products (but I guess this doesn’t necessarily have to be in PHP).