Installing PEAR on WAMP

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

php go-pear.phar

image

3. You will be prompted for install locations.. Accept ALL defaults, and proceed with the setup:

image

4. When the install is complete, the pear installer creates a registry file to help us set the correct paths:

image

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)

image

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

image

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 .

Advertisements

11 thoughts on “Installing PEAR on WAMP

  1. Brilliant.

    Have had so much trouble with WAMP / PEAR in the past and have spent countless hours hunting through various bits of patchy information on the web; eventually I manage to get it working, but it’s so much more painful than it needs to be.

    Your solution worked first time. Consider this post permanently bookmarked (and recommended to everyone in the office).

      1. I have problem to install memcached,
        I got following error when I tried to install memcached.

        ERROR: The DSP memcached.dsp does not exist

        command is pear install pecl/memcahced and pecl install memcached

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 )

Google+ photo

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

Connecting to %s