Installing PEAR and PHPUnit on WAMP and Windows 7

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. Also when this tutorial was written, php was in php5.3.0 folder, please use the path as per your current setup.

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’ . If it gives error, then download this file: 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 


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 

 pear channel-discover

 pear channel-discover

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

  1. Stackoverflow
  2. Wampserver forum
  3. Using Zend Framework blog

36 thoughts on “Installing PEAR and PHPUnit on WAMP and Windows 7

  1. Thank you very very very very very very very much now i am a happy person all works! I try to fix this problem almost a two week so woow with you help and great tutorial i do it in one hour !!!!!!!!!

  2. Perfect tutorial !!!

    The only thing I want to know is: what about C:php5 folder ?
    Should I remove it or I must keep it forever ?

    Days before I started my first YII framework’s star track test-driven script which requires installed PHPUnit. Now everything work. Thx


  3. I don’t normally leave comments, but thank you so very much. After much banging of head on the wall and hours of time wasted.

    Thank you!

  4. If like me it doesn’t work saying that Structures/Graph is missing (windows 7 , php 5.3.5, apache 2.2.17) do the following :
    Go here and download the archive :
    Extract the Structures folder in your C:wampbinphpphp5.3.5PEAR
    Oh and if you have not the latest version by default installation like me (it installs 1.8.0 by default but PHPUnit wants 1.9.1) just run : pear upgrade pear

  5. I followed your instructions and have tried few other posts including the instructions from, but no matter what I do I always get the following error when i use phpunit command from admin command prompt (on a 64bit Win 7 with PHP 5.3.3 install):

    Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in C:Program Files (x86)EasyPHP-.3.3.1phpphpunit on line 38

    Fatal error: require_once(): Failed opening required ‘PHP/CodeCoverage/Filter.php’ (include_path=’.;C:php5pear’) in C:Program Files (x86)EasyPHP- on line 38

    Please suggest what can I do to resolve this issue


  6. I wasted 3 days with installing this wampp and phpunit and stuffs… I lost all hope and at the moment of deleting my entire project directory (with my plans) I came to your post. Worked at first shot itself. Thanx a lot bro

  7. I am using uniserver and every thing went fine.But at last every thing is downloaded but i didn’t find the phpunit.bat file in php folder.

  8. i didn’t find phpunit.bat file because the installation of phpunit was failure.I just reinstalled the whole pear solved the issue.

  9. Tried this to install phpunit and al seemed to go fine but still cannot run it.

    ‘phpunit’ is not recognized as an internal or external command,
    operable program or batch file.

    is what i get from the command line.

    Pear tells me it is installed, when I check the phpunit folder, for me located at: C:wampbinphpphp5.3.0PEARPHPUnit
    there is no batch file in fact there is no file at all, just 2 folders, Extensions and Framework thats it so where is my phpunit.bat file??

  10. I cannot seem to find phpunit.bat, which is required by NetBeans for PHPUnit integration. Is there something else we must do?

  11. Pingback: without the 'a' » Configuring PHPUnit on Wamp 2.x

  12. Pingback: Installing PEAR and PHPUnit on WAMP and Windows 7 « CSS un HTML koda piemēri

  13. Bonjour

    Merci pour ce tutoriel, grâce a votre aide j’ai pu faire un bout de chemin en environnement Windows XP.
    La seule petite chose qui manque dans ton cheminement est le téléchargement de l’archive Structures_Graph-1.0.4.tgz, décompresser et copier le dossier Structure dans C:wampbinphpphp5.3.xPEAR.

    Merci vraiment sinon c’est un puzzle, et ton apport a été la portion la plus importante.

  14. Hi sir am getting following error after I hit -> pear install –alldeps phpunit/PHPUnit

    Starting to download PHPUnit-3.6.10.tgz (118,595 bytes)
    ……………………..done: 118,595 bytes
    Could not delete C:wampbinphpphp5.2.7phpunit, cannot rename C:wampbinphp
    ERROR: commit failed

    Can u please sort this problem out for me.. I have been banging my head for hours …

    note : 1. WAMP version 2.2 with php downgraded to php 5.2.7
    2. Ran cmd with admin rights.

  15. Pingback: PHPUnit – Pear – Windows 7 – PHP 5.4 - Michal "Twisťa" Haták

  16. If like me it doesn’t work saying that Structures/Graph is missing (windows 7 , php 5.3.5, apache 2.2.17) do the following :
    Go here and download the archive :
    When you extract this, you will get a file named “Structures_Graph-1.0.4”. Open it with winzip or winrar and extract again. Then you get a folder which contains ‘Structures’ folder. Copy the ‘Structures’ folder to C:wampbinphpphp5.3.5PEAR.

  17. Am facing the same issue while installing PHPUnit using pear-

    Could not delete C:PHPPearphpunit, cannot rename C:PHPPear.tmpphpunit
    ERROR: commit failed

    Has someone got similar issue and any steps for resolving the same.

    Have used cmd with Admin privileges, but still getting the error and also there is no point in deleting the folder manually as the.tmp has to be renamed post download completion of package.

    Please help

  18. Thanks, Thanks for this article, when I created dir C:php then command: pear install –alldeps phpunit/PHPUnit installed phpunit with success after many hours of trials


  19. Pingback: [Install PHPUnit] Installing PEAR and PHPUnit on WAMP and Windows 7 | My Daily Techs

  20. Hi Amit,

    I tried and followed the same steps, but seems there is something which is wrong, when I run ” pear channel-discover” this command then we get an below mentioned message
    “C:\wamp\bin\php\php5.5.12> pear channel-discover
    Discovering channel over http:// failed with message: channel-add: Cannot open “http
    ://” (File not valid (received: HTT
    P/1.1 410 Gone
    Trying to discover channel over https:// instead
    Discovery of channel “” failed (channel-add: Cannot open “
    nnel.xml” (File not valid (received: HTTP/1.1 410 Gone

    Can you please what I am doing wrong here….. any help much appreciated….

    Thanks in Advance

Comments are closed.