Installing PEAR and PHPUnit with WAMPServer 2.2 on Windows 7 (PHP 5.3.10)

These are my install notes for PEAR and PHPUnit with WAMPServer 2.2 on my Windows 7 development machine. I tried several tutorials before getting the installation right. I hope this blog post helps anyone attempting this or with a broken installation. My setup aims for ease of use in a development environment.

First, PEAR needs to be installed and working 100%.  This Stack Overflow answer was very helpful. These are my additional notes to their instructions:

1. I added my WAMP PHP folder to my PATH (ex: C:\Users\Kate\development\wamp\bin\php\php5.3.10).

2. At the prompt I used system for the install not local. This wasn’t exactly clear in the instructions.

3. The PEAR installer will show an options list for various install paths.

  • Pear suggested putting pear.ini in the Windows folder. Instead, I had it use my WAMP PHP directory (C:\Users\Kate\development\wamp\bin\php\php5.3.10).  Aside from keeping pear.ini out of the Windows folder, this change also removes the need for the command prompt to be run as administrator during install. As part of this change I also set the PHP_PEAR_SYSCONF_DIR system environment variable to the WAMP PHP directory so PEAR could find pear.ini later during the PHPUnit install.
  • I adjusted my web root directory setting which was different from the proposed default.

4. I then installed PHPUnit with the following command sequence. Note the first line will fail if pear.ini is still set to the Windows folder and the command prompt isn’t running as an administrative process OR if the location was changed and the PHP_PEAR_SYSCONF_DIR environment variable wasn’t set (see step 3).

pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit

 

The PHPUnit install is successful when the phpunit command can be run on the command line without fuss. I’ll update this page with additional notes if I hit any other pitfalls from these methods.