---
title: "Installing PEAR and PHPUnit on WAMP and Windows 7"
url: https://thecancerus.com/installing-pear-and-phpunit-on-wamp-and-windows-7/
date: 2010-10-30
modified: 2014-02-23
author: "ican"
description: "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..."
categories:
  - "how too?"
  - "php"
tags:
  - "pear"
  - "phpunit"
  - "wamp"
word_count: 525
---

# 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:
H:\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](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=".;H:\wamp\bin\php\php5.3.0\pear"

;*****
Copy these three lines and paste it to ‘*php.ini*’ file which is located at :
H:\wamp\bin\apache\apache2.2.11\bin
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
‘H:\wamp\bin\php\php5.3.0’
in your path. You also need to add a new variable ‘PHP_PEAR_PHP_BIN’ and set the value to
‘H:\wamp\bin\php\php5.3.0\php.exe’
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](http://phpcamp.net/?utm_medium=blog_post&utm_source=amiworks_co_in&utm_campaign=pear_phpunit_win7).

## 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

- [Stackoverflow](http://stackoverflow.com/questions/1652941/why-am-i-receiving-an-error-when-installing-pear)
- [Wampserver forum](http://www.wampserver.com/phorum/read.php?2,67257)
- [Using Zend Framework blog](http://usingzendframework.blogspot.com/2007/12/setting-up-phpunit.html)