ProgrammingWindows

Installing WAMP and PHPUnit on Windows

By November 5, 2008July 8th, 201443 Comments
  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

43 Comments

  • Chitra.T says:

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

  • Nicolaas says:

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

  • Joshua says:

    Yes I do

  • Peter says:

    Thanks for this tutorial, it worked very well.

  • Diego Toala says:

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

  • George says:

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

      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

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

  • George says:

    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

  • Bapiraju Yarlagadda says:

    Nice Tutorial,
    Its very useful πŸ™‚

  • Gautham says:

    Hi Joshua,

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

    What should I do now?

    Thnaks

    • Joshua says:

      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

  • Gautham says:

    Hi Josh,
    Thanks for the help. Its working!! πŸ™‚

  • sivakumar says:

    Thanks a lot.

  • Mougli says:

    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

  • Mougli says:

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

  • Aditya Sakhuja says:

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

  • Mark says:

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

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

        It’s not “update” but “upgrade”

        So correctly:
        pear –force upgrade PEAR

        Then it works fine, thanks for the hint.

  • Mark Dexter says:

    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.

  • Joaquin Senosiain says:

    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.

  • ravikumar says:

    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

  • Maulik says:

    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.

  • Billy Scholtz says:

    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%

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

    congratulations for the post

  • Fadi Chalfoun says:

    Thanks for the informative and helpful post!

  • 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.
    =)

  • Bhathiya says:

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

  • Good day, i was just wondering if you can use the

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

    without internet connection???

  • Jeeba says:

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

  • aaxc says:

    Just an updated info, how to do it now:

    1. Install WAMP server
    2. Goto C:\wamp\bin\php\php5.3.5
    3. Execute: php -d phar.require_hash=0 PEAR\go-pear.phar
    4. Execute: PEAR_ENV.reg
    5. Execute: pear channel-discover pear.phpunit.de
    6. Execute: pear install phpunit/PHPUnit

    And there you go.

  • aaxc says:

    Dunno why the day says 5th November 2008 for me, but my post is made: 16th August 2011

Leave a Reply