Installing PEAR and PHPUnit on WAMP and Windows 7

October 30th, 2010 | Save to del.icio.us now(0)

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.

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

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

Related posts

  1. How to use SVN and Git together to get the best of both worlds in Windows
  2. How To Fix MySQL Error – Error Code 30
  3. Simple JavaScript ‘Frame Busting’ Code
  4. Where is MySQL Gone Away?
  5. Integrating With Twitter API In CodeIgniter

Wondering what to do next?


(Search web development related contents)


25 Responses to “Installing PEAR and PHPUnit on WAMP and Windows 7”

  1. November 5, 2010 9:55 am Gayane says

    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. November 10, 2010 12:12 pm Kris says

    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,

  3. November 10, 2010 12:21 pm Amit Kumar Singh says

    @kris I am not really sure.. about ‘php5′ folder, i will say let it be.

  4. November 13, 2010 1:20 pm Darren Roberts says

    Smashing stuff thanks – had many problems with getting pear & phpunit set up on wamp, and this nailed it,

    D

  5. November 27, 2010 2:32 am Seb says

    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!

  6. December 3, 2010 4:45 pm perk says

    thanks for this tutorial.
    you have been a great help!

  7. December 5, 2010 12:55 pm Errol says

    It took me 3 1/2 hours to get this installation… thanks a lot!

  8. December 30, 2010 12:56 pm arpita says

    Thanks for the tutorial sir….
    Finally solved my problem.

  9. January 12, 2011 6:35 pm Sly says

    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

  10. January 13, 2011 12:26 am psiborg says

    This command you mentioned saved the day for me:

    pear upgrade pear

    Thanks!

  11. February 9, 2011 4:05 am Anurag says

    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

  12. February 11, 2011 4:32 pm Mark says

    Thank you! You saved me hours of frustration!

  13. February 11, 2011 5:46 pm Amit Kumar Singh says

    @anurag you need to install CodeCoverage pear package as well.

  14. February 13, 2011 4:32 pm Vasanth says

    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

  15. February 15, 2011 12:11 am yuri says

    thxm but where is .bat?

  16. February 16, 2011 9:19 pm Lupida says

    OMFG! Thank you SO much! After two days of screaming (and fiddling around) it finally works!

  17. February 21, 2011 2:21 pm RSK says

    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.

  18. February 22, 2011 12:29 pm RSK says

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

  19. February 28, 2011 1:23 am Ken says

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

  20. March 18, 2011 7:26 am Hindol says

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

  21. March 18, 2011 7:28 am Hindol says

    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

  22. March 19, 2011 1:09 am mariek says

    That’s sooo great ! thanks a lot for your help, it’s all clear and well explained.

  23. March 28, 2011 12:18 am without the 'a' » Configuring PHPUnit on Wamp 2.x says

    [...] PHPUnit on my Wamp install, I ran into nothing but headaches, even after following the numerous tutorials I found [...]

  24. April 11, 2011 3:15 pm Installing PEAR and PHPUnit on WAMP and Windows 7 « CSS un HTML koda piemēri says

    [...] 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 » [...]

  25. June 30, 2011 10:19 pm SEMASSOU MARIE NADEGE says

    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.

Trackback URI | Comments RSS

Say Something, and Be Counted

Name (required)

Email (required)

Website

Speak your mind