Feb 26, 2011 Update: I finally managed to get PEAR and PHPUnit installed on WAMP. Click here for details
For the life of me, I could not get PHPUnit to install properly using the regular PEAR install process (and, most online installation instructions are either geared towards MAMP or LAMP). So, I thought I would document the easiest way to get it working for a WAMPServer setup.
Step1: Download the following files onto a location of your harddrive from http://pear.phpunit.de/
Step2: Unzip all and copy them into the PEAR install directory (not a requirement, just a convenient location to store them. The path will need to be added to the include_path in php and the “path” environment variable of windows).
Pay attention to the placing of PHP_TokenStream components.. The phptok.bat and phptok.php should be placed in the mean pear directory.. and the token.php and token subfolder go into the PHP directory.
Also, Timer.php extracted from PHP_Timer goes into the “PHP” folder.
After the unzip, your directory should look like this:
Step3: Add a “UserVariable” named PHPBIN pointing to the location of php.exe on your system.
Add the path into the OS path “System variable” as well:
Finally, add it to the include_path setting in php.ini.. This is what mine looks like:
include_path = “.;D:\wamp\bin\php\php5.3.0\Zend\ZendFramework-1.9.4\library;D:\wamp\bin\php\php5.3.0\PEAR”
Step4: Prepare the files:
a. Edit “PHPUnit.bat” and change the last line to include the actual full PEAR path. And, change phpunit to phpunit.php like so:
“%PHPBIN%” “@bin_dir@\phpunit” %*
“%PHPBIN%” ” D:\wamp\bin\php\php5.3.0\PEAR\phpunit.php” %*
b. Edit “PHPCov.bat” and change the last line to include the full PEAR path, and change phpcov to phpcov.php:
“@php_bin@” “@bin_dir@\phpcov” %*
“@php_bin@” “D:\wamp\bin\php\php5.3.0\PEAR\phpcov.php” %*
c. Edit “PHPTok.bat : repeat the same edits as in step b.
The last line should look like:
“@php_bin@” “D:\wamp\bin\php\php5.3.0\PEAR\phptok.php” %*
Now, you should be all set to run your phptest cases. To verify that your install is successful, open up a command window and type phpunit. You should receive correct usage directions.