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.
So let’s start with PEAR, please note my Wampserver is installed on drive ‘H’, substitute it with your own.
Steps to Install PEAR
1 ) Locate the "php.ini" file. In my case, I found it at this path:
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’
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=".;H:wampbinphpphp5.3.0pear" ;*****
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.
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