I do most of my php development on Windows (using Wampserver on Windows 7). Unfortunately, the default Wampserver installation does NOT provide PHPUnit – the unit testing tool for PHP.
PHPUnit is distributed via PEAR repositories. While installing the PEAR repository is a cinch on Linux, I am honestly surprised about how convoluted it is on a WAMP setup (actually, it is the lack of accurate documentation that is troubling. I tried the process some time ago and faced a similar problem. At the time, I wrote a blog about setting up PHPUnit manually).
So, here is my attempt at detailing the (fully working!) PEAR (and PHPUnit) install process step-by-step with all the gory details:
1. Right click on the following link: http://pear.php.net/go-pear.phar and save as go-pear.phar in your wamp/bin/php directory (C:\wamp\bin\php\php5.3.4 in my case)
2. Open an ADMIN command window, navigate to the folder where go-pear.phar was downloaded and type in
3. You will be prompted for install locations.. Accept ALL defaults, and proceed with the setup:
4. When the install is complete, the pear installer creates a registry file to help us set the correct paths:
5. The PEAR_ENV.reg file is generated as shown in the explorer window below.. Double click to launch and update your registry (it merely sets up path variables and global constants so that the pear files are accessible from the command line)
6. Now, you should have PEAR installed on your computer. The next step is to register the channels that we require to download PHPUnit. Various repositories are required, it is easiest to run the following command and let PEAR figure out required channels:
(Make sure you have both openssl and curl support in your php installation. You may need to uncomment the corresponding .dll load commands in your php.ini… Remember, the CLI’s php.ini NOT your apache’s.. In case you have wampserver installed, there IS a difference!)
C:\wamp\bin\php\php5.3.4>pear config-set auto_discover 1
7. Now that we have all sources established, issue the command to install the phpunit files. The ‘- – alldeps’ parameter is REQUIRED to install the command line tools for PHPUnit
pear install -a pear.phpunit.de/PHPUnit
You should now have all the required components for phpUnit to function normally.
Here’s how you can also install Doctrine ORM:
pear install pear.doctrine-project.org/DoctrineORM-2.2.2
pear install doctrine/DoctrineSymfonyConsole
There are a bunch of useful php utilities that use pear. Please refer to this blog to learn about all the cool tools you can use to enhance your PHP coding .