Setting up PHPUnit (on Wamp)

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

a. PHPUnit
b. File_Iterator
c. PHP_CodeIterator

d. Text_Template
e. PHP_TokenStream
f. PHP_Timer

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.

Also, note that Netbeans offers excellent integration with phpunit. Read more about this here:


One thought on “Setting up PHPUnit (on Wamp)

  1. thank you, I found my answer in this article
    “@php_bin@” “D:\wamp\bin\php\php5.3.0\PEAR\phpcov.php” %*

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s