[Install PHPUnit] Installing PEAR and PHPUnit on WAMP and Windows 7 (no longer maintained from PHPUnit 3.7)

First of all, thanks to @Sebastian Bergmann for reminding and sorry for my careless about this reblog because End of Life for PEAR Installation Method to PHPUnit from github and The package PHPUnit is not maintained anymore and has been superseded. Package has moved to channel pear.phpunit.de, package PHPUnit from pear.php.net.

So this blog should be a reblog of installing PHPUnit(<3.7) in Windows7 from http://thecancerus.com/ and I found it was still useful for understanding the theory of configuration of php(in wamp) and the environment variables.

The newest manual installation of PHPUnit in windows can be found its documentation.

I didn’t really change the original blog but generalize several configurations :

In the project that i am currently working on, we decided to use PHPUnit for doing our unit testing, and i found that it was not a straight forward thing to install that I had thought it would be. I had to start by installing Pear, and as soon as i type ‘go-pear’ in command prompt and pressed enter key I got my first error.

So here are the steps needed to install PEAR and PHPUnit error free on WAMP.

Steps to Install PEAR

1 ) Locate the “php.ini” file.

Your_php_path\php.ini (ex. C:\wamp\bin\php\php5.3.0\php.ini)

Don’t use the WAMP system tray icon to edit this file.

2 ) Find the following line:

;phar.require_hash = On

3 ) Uncomment the “;phar.require_hash = On” line by removing the semi-colon.

4 ) Change “On” to “Off”.

phar.require_hash = Off

5 ) Save the file.

6 ) Now on command prompt type ‘go-pear’ . If it gives error, then download this file: http://pear.php.net/go-pear.phar put it in php folder and try this step again.

6 a)  If you installed phar file in the instruction above, then use command

php go-pear.phar

to install pear.

7 ) Select ‘local’ to the question asked.. and follow the instructions.

8 ) Now we need to edit the ‘php.ini’ again to add pear include path. Open ‘php.ini’ that we found in php5.3.0 folder and search for ‘go-pear’, you will see

;***** Added by go-pear
include_path=".;your_php_path\pear" (ex. include_path=".;C:\wamp\bin\php\php5.3.0\pear")

Copy these three lines and paste it to ‘php.ini’ file which is located at :


9 ) Restart the apache, and you have PEAR installed on you machine.

But we are not done yet, to use ‘pear’ command in your command prompt from anywhere you will need to modify the windows environment variables.

10 ) Go to control panel –> system  and click on the ‘advanced system settings’ (it is on the left sidebar)

11 ) Click on the environment variables button and new/edit ‘PATH’ variable and add


in your path. You also need to add a new variable ‘PHP_PEAR_PHP_BIN’ and set the value to


close you command prompt and open it again for these changes to take effect.

12 ) now type ‘pear’ on the command prompt and you should see pear command help printed for you.

Now that PEAR is installed, let’s install the PHPUnit.
Check out PHPCamp a place to share news, views and articles that are useful to PHP community.
Steps to install PHPUnit

1 ) On ‘C’ drive create a folder named ‘php5’

2 )Then on command prompt type:

pear upgrade pear

2 ) Once PEAR  is updated, on command prompt type:

pear channel-discover components.ez.no

pear channel-discover pear.phpunit.de

pear channel-discover pear.symfony-project.com

4 )Finally type:

pear install --alldeps phpunit/PHPUnit

And with this you should have PHPUnit installed on your system.

In my quest to install PHPUnit I found help from following articles

Wampserver forum
Using Zend Framework blog


Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s