Installing PEAR and PHPUnit on Windows 7 (WAMP)

Just a quick and dirty walkthrough for the end goal of installing PHPUnit on a Windows 7 machine running WAMP. These steps should be fine for other versions of Windows and WAMP. Really the structure of the stack does not have a huge impact on the installation of both PEAR and PHPUnit.


PEAR stands for “PHP Extension and Application Repository” and is a distributed system of pre-built packages that extend the functionality of PHP very easily, often without the need for manual configuration changes to PHP itself. Think of it like an App Centre for PHP.

Since PHPUnit is one of these packages, we need to have this installed beforehand. NOTE: replace [version] with the version of PHP you are using:

  1. In Windows Explorer, go to your WAMP PHP installation folder (default will be C:\wamp\bin\php\php[version]).
  2. Create a new directory called “PEAR” here.
  3. Download the PEAR phar installer and place it in the new directory above.
  4. Fire up a cmd window (Start and search for “cmd”) as administrator
  5. Change to your new directory (default command will be “cd C:\wamp\bin\php\php[version]\PEAR”)
  6. Run the following command: “php go-pear.phar”
  7. The first thing that the installer will ask is whether you are installing a system wide copy of PEAR. Since you are probably working on a development machine, either is fine. Just press enter to install system wide.
  8. Next, the installer will show you a bunch of paths that it automatically calculated by using it’s current location on your disc.
    [blockquote]NOTE: One problem I did run into here was that these paths were picking up paths for an old, and long gone, version of PHP. This was because I had installed PEAR before when that version of PHP was on my machine. As a result, there were some Environment Variables still in my system. If the same happens to you, make sure you remove all Environment Variables relating to PEAR.

    1. Right click “Computer”.
    2. Go to “Properties” -> “Advanced System Settings”.
    3. Hit the “Environment Variables” button at the bottom
    4. Delete everything relating to PEAR in the top box.
    5. Restart the installer above.


  9. If the paths are all in order, hit Enter. The installer will start doing it’s thing.
  10. A warning may pop up:
    [code]WARNING! The include_path defined in the currently used php.ini does not contain the PEAR PHP directory you just specified.[/code]
    The installer will ask if you want it to write to it now, which you should do. But often the installer has picked out the wrong ini path anyway. Usually WAMP uses the php.ini file located in the Apache directory. In any case, make sure by going down to your WAMP system tray and going to PHP -> php.ini and doing a search for “include_path”. You want to alter the line that looks like this:
    ; Windows: “\path1;\path2”
    ;include_path = “.:/php/includes”
    To look like this:
    ; Windows: “\path1;\path2”
    include_path = “.;c:\wamp\bin\php\php[version]\pear”
  11. Finally, the installer is going to create a reg file in your PEAR directory to add Environment Variables to the system. Press enter to complete the installation
  12. Go to your new PEAR directory. You will see a new PEAR_ENV.reg file. Double click this and click Yes to add the new Environment Variables
  13. And finally, lets make life easier for ourselves by putting the path to PEAR in our System Path. Right click Computer -> Properties -> Advanced system settings and hit the Environment Variables button. This time, in the bottom window, find and double click the item called “Path”. In the popup, add this to the end of the current string: “;C:\wamp\bin\php\php[version]\PEAR”. Click OK twice and restart your cmd window.

Congrats, you just installed pear. Restart your WAMP server, and go pack to the cmd prompt to test. All you have to do to test is type “pear” and press enter. A list of options will appear (and not a “command not found” error). Keep this cmd prompt open for the next step.


  1. In your cmd prompt, navigate to your PHP directory. (default will be C:\wamp\bin\php\php[version])
  2. Run the following commands:
    pear channel-discover
    pear channel-discover
    pear channel-discover
    pear install –alldeps phpunit/PHPUnit
  3. Press enter and wait for pear to do it’s thing.
  4. Test that installation is complete by typing “phpunit” in your cmd window. A list of options should display.

14 thoughts on “Installing PEAR and PHPUnit on Windows 7 (WAMP)

  1. After I enter “pear install –alldeps phpunit/PHPUnit”

    I get the message

    No releases available for package “”
    install failed

    What went wrong?

  2. Thanx for the help, it really helped me, I was looking outdated tutorial moments ago, and then i found yours. Really Helpful.

  3. Just wanted to add, I too just had the same issue with

    pear install –alldeps phpunit/PHPUnit

    updating the channels didn’t work, but I just did pear clear-cache, tried it again, and Sucess!! Thanks guy for this actual functional tutorial! Next step, setting up Zend!

  4. After searing in google for log while , i got this help full tut, which helps me to overcome the PEAR and PHPUnit installation issue thank you

  5. Hey thanks for the info..! I have been having a hell of a time trying to get PHPUnit going with WAMP.

    At first I was trying to load it as a Composer dependency, but couldn’t get that happening. So I figured I would install it globally .. found your site… followed the instructions.

    But still no love. 🙁

    – I added the PEAR folder to bin/php/php5.4.12/ in WAMP
    – I put the go-pear.phar in the folder and ran as admin
    – I didn’t have any wonky paths in my environment
    – I uncommented the include path in WAMPs php.ini and directed it to the PEAR folder
    – I double clicked the .reg file and it added good paths to Environment
    – restarted WAMP server and restarted Cygwin

    ::AND NOTHING!!! AAAAAR!! Command Not Found!::

    So .. I’m a Mac guy and am not so handy yet on my new (temporary) Windows machine. I have no idea how to troubleshoot this. As far as I can see .. it should be working. Why does my computer disagree?

    (I’m on Windows 8 .. btw)

    So .. I have now spent my entire Sunday afternoon trying to get PHPUnit running on WAMP … and here I am at 11pm exactly where I started. Not a happy camper today. Nope.

    Any ideas what I can try?

Leave a Reply

Your email address will not be published. Required fields are marked *