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.
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’
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.
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
Related posts
- How to use SVN and Git together to get the best of both worlds in Windows
- How To Fix MySQL Error – Error Code 30
- Simple JavaScript ‘Frame Busting’ Code
- Where is MySQL Gone Away?
- Integrating With Twitter API In CodeIgniter
Filed under how too?, php | Comments (25)
25 Responses to “Installing PEAR and PHPUnit on WAMP and Windows 7”



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 !!!!!!!!!
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
Regards,
@kris I am not really sure.. about ‘php5′ folder, i will say let it be.
Smashing stuff thanks – had many problems with getting pear & phpunit set up on wamp, and this nailed it,
D
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!
thanks for this tutorial.
you have been a great help!
It took me 3 1/2 hours to get this installation… thanks a lot!
Thanks for the tutorial sir….
Finally solved my problem.
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 : http://download.pear.php.net/package/Structures_Graph-1.0.4.tgz
Extract the Structures folder in your C:\wamp\bin\php\php5.3.5\PEAR
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
This command you mentioned saved the day for me:
pear upgrade pear
Thanks!
I followed your instructions and have tried few other posts including the instructions from http://www.phpunit.de/manual/3.6/en/installation.html, 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.1\php\phpunit on line 38
Fatal error: require_once(): Failed opening required ‘PHP/CodeCoverage/Filter.php’ (include_path=’.;C:\php5\pear’) in C:\Program Files (x86)\EasyPHP-5.3.3.1\php\phpunit on line 38
Please suggest what can I do to resolve this issue
Thanks!
Anurag
Thank you! You saved me hours of frustration!
@anurag you need to install CodeCoverage pear package as well.
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
thxm but where is .bat?
OMFG! Thank you SO much! After two days of screaming (and fiddling around) it finally works!
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.
i didn’t find phpunit.bat file because the installation of phpunit was failure.I just reinstalled the whole pear solved the issue.
Thankz
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:\wamp\bin\php\php5.3.0\PEAR\PHPUnit
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??
I cannot seem to find phpunit.bat, which is required by NetBeans for PHPUnit integration. Is there something else we must do?
UPDATE:
pear install –alldeps –force phpunit/phpunit
- This solved my problem regarding phpunit.bat
Reference: http://stackoverflow.com/questions/5301639/how-can-i-get-a-phpunit-bat-after-install-phpunit-via-pear
That’s sooo great ! thanks a lot for your help, it’s all clear and well explained.
[...] PHPUnit on my Wamp install, I ran into nothing but headaches, even after following the numerous tutorials I found [...]
[...] http://amiworks.co.in/talk/installing-pear-and-phpunit-on-wamp-and-windows-7/ Komentēt LikeBe the first to like this post.Komentēt » [...]
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:\wamp\bin\php\php5.3.x\PEAR.
Merci vraiment sinon c’est un puzzle, et ton apport a été la portion la plus importante.