Monthly Archives: August 2011

Setting up PHPUnit with MAMP

After a few hours of Googling and headdesking, I finally got PHPUnit up and running in my local environment. In the end, I had to make reference to a bunch of different resources. It was a convoluted enough process that I don’t think I can replicate step-by-step instructions, but I can at least list some of the stumbling blocks I hit along the way.

My setup: OSX (10.6.8), running PHP 5.3.2 from the MAMP package. Generally, the commands I give here will have to be run as root; use either sudo each time or enter the root prompt with sudo su.

The basic instructions for installing PHPUnit tell you to use PEAR:
[code language=”bash”]
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install –alldeps phpunit/PHPUnit
[/code]
But when you’re running MAMP, ‘pear’ may point to the wrong version of PHP – the version that comes bundled with OS X, or another of the versions that comes with MAMP. Make sure that you’re referencing the proper one (source). In my case, that means:
[code language=”bash”]
/Applications/MAMP/bin/php5.3/bin/pear channel-discover pear.phpunit.de
[/code]
and so forth.

As noted here and elsewhere, PHPUnit requires at least PEAR 1.8.1, but MAMP (or at least the version I have installed) ships with an earlier release. (You’ll know that this is the case, because when you try installing PHPUnit with the commands above, you’ll get a bunch of messages about required versions.) When I tried upgrading PEAR with the internal
[code language=”bash”]
/Applications/MAMP/bin/php5/bin/pear channel-update pear.php.net
/Applications/MAMP/bin/php5/bin/pear upgrade pear
[/code]
I got a “Nothing to upgrade” message. I ended up doing a sort of manual upgrade, using step 6 of these instructions:
[code language=”bash”]
cd /Applications/MAMP/bin/php5.3
curl -O http://pear.php.net/go-pear.phar
php go-pear.phar
[/code]
and then following the on-screen instructions for configuring PEAR.

I found that, in my situation, the automatically generated PEAR configuration files pointed to the wrong version of PHP. I used the instructions in this comment to lead me in the right direction. More specifically, when I looked at the PEAR config settings
[code language=”bash”]
pear config-show
[/code]
I saw immediately that some of the paths were pointing to the wrong version of PHP (at /Applications/MAMP/bin/php/ rather than /Applications/MAMP/bin/php5.3/). I reconfigured the necessary paths like so:
[code language=”bash”]
pear config-set doc_dir /Applications/MAMP/bin/php5.3/lib/php/doc
[/code]
and so on.

This got me to the point where I could fire up PHPUnit on my version of PHP, without getting a ‘command not found’ error. However, I didn’t get very far in my testing, because I kept getting fatal errors. In my PHP error logs, I could see that lines in PHPUnit, like the following, were failing to find their targets:
[code language=”php”]
require_once ‘PHPUnit/Autoload.php’;
[/code]
This suggested that the include_path in my php.ini didn’t have the correct directory. So I opened it up (on my installation, it’s at /Applications/MAMP/conf/php5.3/php.ini). It turns out that PEAR had attempted to rewrite the include_path directive but it had pointed to the wrong path for my purposes. I appended the following path (which is where PEAR keeps the PHPUnit package files): /Applications/MAMP/bin/php5.3/lib/php/PEAR

Et voilĂ  – it finally worked:
[code language=”bash”]
phpunit –version
# PHPUnit 3.5.15 by Sebastian Bergmann.
[/code]

They’ve got Wally covered

We came back from a mini-vacation in Wisconsin yesterday to find a package on our table addressed to Wally. Inside was this beautiful quilt:

The very cute card was inscribed, in part: “Commissioned by Paul Gibbs. Made by Andrea Rennick”. Paul and the Rennicks are a few of my friends from the WordPress and BuddyPress world, each of whom I’ve met in person exactly once. Lately there has been no shortage of reminders that online friends are the real deal; having some of that kindness directed toward me and my family brings it all home. It’s a nice reminder that our geographical distribution – Paul is in Old Blighty, and the Rennicks are in the frozen north – doesn’t change the fact that we’re real coworkers, and real friends.

As a bonus, you can check out a set of making-of photos.

Thanks, Paul, Andrea, and Ron!

Anthologize 0.6

I just tagged version 0.6-alpha of Anthologize in the wordpress.org plugin repo. This new version has a bunch of bug fixes, improvements to stability and consistency of output, and a few new feature goodies. Read more about the release here.

On a related note, Anthologize development has recently moved 100% over to our Github repo. We’d previously used Trac for ticketing and Github for code management, but now we’re doing everything on Github. If you’re a user, please feel free to open new issues. If you’re a developer, send those pull requests!