Please don’t create something that uses PEAR
This weekend I was looking into testing PHP code and wanted to try out some libraries. After looking around I decided PHPUnit, SimpleTest and Testify where looking nice.
Testify has great looks and is very simple, but licensed under GPL and I don’t want to GPL every project where I drop the Testify projectfiles into. So Testify is out.
Then I looked into SimpleTest. Installation was a breeze, just dropped the files into my project. Read some “Getting started” docs and I was running some tests. Nice!
But then I was reading a lot of people complaining that SimpleTest is way behind PHPUnit. So I decided to try out PHPUnit and was surprised that they already advice to use PHP 5.4 with their newest version. Great! Lets install it!
The installation guide told me to use PEAR, I didn’t have PEAR installed on my Mac so needed to install it. There was a link to the PEAR install guide, I followed it and it wanted to install PEAR into my home folder. Not a good idea, so time to Google.
Then I found that there was already an installer on my Mac. I runned it and now I have PEAR. Nice!
Next step; Run the installation commands for PHPUnit. Some output on the console and everything seemed fine. Well, not too bad!
But when I wanted to run the test PHPUnit threw a bunch of errors on me. Not cool! Looking up these errors on Google showed not a really clear solution, but after combining some StackOverflow posts I tried to add a include path in my php.ini. So I added:
include_path = /usr/lib/php/pear/
to my php.ini and tried again. It worked, finally time to some real testing!
PHPUnit looks great, nice features and good docs, but I’m not looking forward to ask my co-workers to install PHPUnit using PEAR. Every time I have to use PEAR (and yes, I’ve used it before to install some extensions) it guarantees troubles. Always some strange errors you have to solve.
So if you have a choice when creating a library, please create something that’s just a drop in library and do not make a PEAR based library/tool.