November 5, 2008

Installing WAMP and PHPUnit on Windows

Posted in How-to, Programming tagged , , , , at 11:30 am by Joshua

  1. Download and Install WAMP
  2. Once you have installed and setup WAMP, open up the command prompt and go to your php directory in WAMP

    C:\>cd wamp\bin\php\php5.2.5

  3. From here you must run the go-pear.bat file to install PEAR and all the files needed for it

    C:\wamp\bin\php\php5.2.5>go-pear.bat

  4. When executed PEAR will ask you a series of question to set itself up correctly, if you don’t know what your doing then just accept the defaults
  5. Once installed you must run the PEAR_ENV.reg which will create the environment variables for the user, so that PEAR can be called in any directory on the command line>

    C:\wamp\bin\php\php5.2.5>PEAR_ENV.reg

    For me, it seemed to work no problem, but if you cannot call PEAR from the command prompt, then you must manually add the directory to the path in the Environment Variables list, found in System Properties -> Advanced-> Environment Variables, then add the directory C:\wamp\bin\php\php5.2.5 to the PATH variable

  6. Once you have PEAR setup, then you must register the PHPUnit channel with PEAR

    C:\wamp\bin\php\php5.2.5>pear channel-discover pear.phpunit.de

  7. Now you can use the PEAR to install packages from the PHPUnit channel

    C:\wamp\bin\php\php5.2.5>pear install phpunit/PHPUnit

  8. You should now find the PHPUnit source files under the PHP directory

…Happy Days

42 Comments »

  1. Very Good tutorial.

  2. Chitra.T said,

    This is a very simple and excellent tutorial…This helped me a lot. Thank you…

  3. Nicolaas said,

    when you say command line do you mean the windows command line?

  4. Joshua said,

    Yes I do

  5. Peter said,

    Thanks for this tutorial, it worked very well.

  6. Diego Toala said,

    Hi Joshua, thanks a lot , your tutorial is great, simply and useful, Im in a project and We are using Visual Studio 2008 with the VS.PHP plugin, MS Source Safe as Source Control and IIS7 as web server wtih FastCGI, and now phpunit, thanks!!!

  7. George said,

    Hello,

    I was trying to install PHPUnit with WAMP in Windows. I was trying the exact way you described in this post, but getting an Error:

    No releases available for package “pear.phpunit.de/PHPUnit”
    Cannot initialize ‘channel://pear.phpunit.de/PHPUnit’, invalid or missing package file
    Package “channel://pear.phpunit.de/PHPUnit” is not valid
    install failed

    Please suggest me what to do

    Many thanks in advance

    • Joshua said,

      Hi George,
      First off did you get PEAR working? If so, did you get any errors when trying to register the PEAR channel? using the line:
      pear channel-discover pear.phpunit.de
      This basically setups up PEAR to use ‘pear.phpunit.de’ as a package source for its repository.

      After that, are you typing exactly:
      pear install phpunit/PHPUnit
      Be sure to include the ‘slash’, with both case of phpunit. I don’t really know if it makes a difference, but it worked for me.
      Also, I know it may sound simple, but make sure your internet connection is active.

      Let me know how it goes George

      Josh

  8. Alan Seiden said,

    Great tutorial. Just one correction: the last two steps show the current path as C:\Program Files\PHP when it should be C:\wamp\bin\php\php5.2.5.

    • Joshua said,

      Thanks Alan!
      Your right, I made a note and updated the post

      Josh

  9. George said,

    Thanks a lot Joshua for your promt reply.

    Yes I got error when trying to register the PEAR channel.
    pear channel-discover pear.phpunit.de

    So I downloaded the “http://pear.phpunit.de/channel.xml” to my pc and added that channel using
    pear channel-add

    Thanks

    George

  10. Bapiraju Yarlagadda said,

    Nice Tutorial,
    Its very useful :-)

  11. Gautham said,

    Hi Joshua,

    Discovery os channel “pear.phpunit.de” failed, is the error message I got.

    What should I do now?

    Thnaks

    • Joshua said,

      Hi Gautham,
      I check the channel, and it is working. All the help that I can offer is that make sure that you have pear in your CLASSPATH list, under your Environment Variables in the System Properties. To test just type ‘pear’ in the command prompt, and it should spit out all the command for pear. If not just navigate to the ‘wamp\php\php5.2.6\‘ directory (or whatever version of php you are using), and type ‘pear‘, the same thing should happen. If you get nothing, then pear was not setup correctly. Second, try running ‘go-pear.bat’ again, it may be your settings.
      Good Luck, let me know what happens.
      Josh

  12. Gautham said,

    Hi Josh,
    Thanks for the help. Its working!! :)

  13. sivakumar said,

    Thanks a lot.

  14. Mougli said,

    Hi

    I tried to install PHPUnit on wamp, but I get an error in step 7. I get message – Discovery of channel “pear.phpunit.de” succedeed and than when I write pear install phpunit/PHPUnit I get an error. I put screen on the web cuz I don’t know which part of it is important and I don’t want to miss something :)

    http://www.shrani.si/f/3H/11k/ZyJxj4n/screen.jpg

    Thanks for your help in advance :)

    Mougli

    • porquero said,

      You must upgrade:
      pear upgrade-all

      • Emilie said,

        thank you very much, it’s ok !

  15. Mougli said,

    It’s OK. I installed the newest version of wamp and everything works perfect.

  16. Aditya Sakhuja said,

    Hi,

    Great tutorial – However, due to windows vista security issues – I get this.

    pear/PEAR can optionally use package “pear/XML_RPC” (version >= 1.4.0)
    ERROR: Adding package pear.php.net/Archive_Tar to registry failed
    ERROR: Adding package pear.php.net/Console_Getopt to registry failed
    ERROR: Adding package pear.php.net/Structures_Graph to registry failed
    ERROR: unable to unpack phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.7.2.tar

    Any clue how to get around it. ?

  17. Mark said,

    C:\wamp\bin\php\php5.2.5>PEAR_ENV.reg

    C:\wamp\bin\php\php5.2.5>pear channel-discover pear.phpunit.de
    Adding Channel “pear.phpunit.de” succeeded
    Discovery of channel “pear.phpunit.de” succeeded

    All went well untill here……..

    C:\wamp\bin\php\php5.2.5>pear install phpunit/PHPUnit
    Did not download optional dependencies: pear/Image_GraphViz, pear/Log,
    deps to download automatically
    phpunit/PHPUnit requires PEAR Installer (version >= 1.8.1), installed v
    1.6.1
    phpunit/PHPUnit can optionally use package “pear/Image_GraphViz” (versi
    .1)
    phpunit/PHPUnit can optionally use package “pear/Log”
    phpunit/PHPUnit can optionally use PHP extension “pdo_sqlite”
    No valid packages found

    I’m not used to Windows or PEAR. Is there an equivilant of
    yum update pear or pear update? I pretty much followed the instructions.
    If you have a quick answer I would appreciate some help. Meanwhile, off to google again! ;-)

    Cheers,
    Mark.

    • Mark said,

      Found it. Well a few things.

      Following the instructions hear seems to leave you with the pear installer 1.6.x. I have never installed this stuff before so I can assume it came down the pipe today. After googling someone suggested that I use pear install -all phpunit/PHPUnit
      That didn’t work, no switch all. I figured out the switch was –alldeps. That looked like it worked, but it didn’t.

      I have Windows XP SP3 in this thing so following the instructions (as of today, I don’t doubt it worked before.

      1. Follow the instructions
      2. pear –force update PEAR
      That gets all the required tools installed
      3. pear install –alldeps phpunit/PHPUnit
      4. Bounce Apache
      5. Get into Control Panel->Properties->Environmental variables->System->Path and click ‘ADD’
      6. close any DOS windows and restart them.
      7. Enjoy!

      I hope this helps another suffering Windows newbie ;-)

      Mark.

      • Dave said,

        It’s not “update” but “upgrade”

        So correctly:
        pear –force upgrade PEAR

        Then it works fine, thanks for the hint.

  18. Mark Dexter said,

    Thanks. Actually the command that worked for me was:

    pear upgrade PEAR

    This upgraded the PEAR to 1.8.1. Then the normal

    pear install phpunit/PHPUnit worked successfully.

  19. Joaquin Senosiain said,

    I follow your instructions, but when i execute c:\php\phpuint, instead of the version info, I get a warning and an error.

    Warning: require_once(PHPUnit/Util/Filter.php): failed to open stream: …

    Not sure if I did something wrong.

  20. ravikumar said,

    when i double click the registration file an error was occured. The error is the registry editing is disabled by your administrator. pls help me

  21. Maulik said,

    when i am going to run 7th point
    pear install phpunit/PHPUnit
    its giving error like this.

    No releases available for package “pear.phpunit.de/PHPUnit”
    Cannot initialize ‘channel://pear.phpunit.de/PHPUnit’, invalid or missing packag
    e file
    Package “channel://pear.phpunit.de/PHPUnit” is not valid
    install failed

    and also when i am writing pear in command prompt anywher it saws unrecognized error but when in /wamp/bin/php/php5.2.6/
    it shows list of PEAR commands..

    tell me whats the problem.

  22. [...] can be downloaded and used right away. The PHPUnit manual advises to use PEAR to install PHPUnit. Joshua Doodnauth explains how to activate PEAR and how to install PHPUnit on WampServer. However, as I was running [...]

  23. Billy Scholtz said,

    Thanks, I had some problems to get it going on Vista. You solved it. I prefer not to use xamp in my setup. Installed PHP manually, gives more control. Your suggestions still worked 100%

  24. When installing PHPunit i got some errors.
    I solved them typying “pear upgrade-all”.

    congratulations for the post

  25. Fadi Chalfoun said,

    Thanks for the informative and helpful post!

  26. shaded said,

    this is the only upgrade option that worked for me

    pear upgrade –force http://pear.php.net/get/Archive_Tar http://pear.php.net/get/XML_Parser http://pear.php.net/get/Console_Getopt

  27. Diego Toala said,

    If you have problems with the upgrade or the install process, use

    peardev upgrade PEAR
    peardev channel-discover pear.phpunit.de
    peardev install phpunit/PHPUnit

    It worked for me , I have Windows 7 64x + Wamp

    peardev is the same command as pear but has unlimited memory

    Regards from Ecuador.
    =)

  28. Bhathiya said,

    My problem solved with this tutorial you r great
    thanks a lot

  29. [...] Installing WAMP and PHPUnit on Windows [...]

  30. Jeeba said,

    Thanks dude, you make may day, Happy Christmas ^^

  31. [...] While I’m using Windows 7, I need to put some crack on googling it. And that brought me to Joshua Doodnauth’s WebLife. The post is about installing PHPUnit in wamp server. So, it’s exactly what I needed since [...]

  32. uditha said,

    Excellent! I have done it.

  33. surendias said,

    thanks this helped me alot. :)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.