How to install PEAR on Windows

There was a PEAR installer go-pear.bat that referred to ./PEAR/go-pear.phar in php versions prior to 5.3 on Windows. But since version 5.3 this installer is absent. Strange enough but official PEAR installation guide still refers to the absent go-pear.bat file. But then it writes about update of PEAR installation by requesting a new go-pear.phar and that is what we should actually do at the beginning.

1. Download go-pear.phar from http://pear.php.net/go-pear.phar and save it in the php root folder.

2. Run php go-pear.phar in a Windows command prompt to start the installation process.

C:\lib\php\PEAR>php go-pear.phar

Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : C:\lib\php\PEAR
 2. Temporary directory for processing            : C:\lib\php\PEAR\tmp
 3. Temporary directory for downloads             : C:\lib\php\PEAR\tmp
 4. Binaries directory                            : C:\lib\php\PEAR
 5. PHP code directory ($php_dir)                 : C:\lib\php\PEAR\pear
 6. Documentation directory                       : C:\lib\php\PEAR\docs
 7. Data directory                                : C:\lib\php\PEAR\data
 8. User-modifiable configuration files directory : C:\lib\php\PEAR\cfg
 9. Public Web Files directory                    : C:\lib\php\PEAR\www
10. Tests directory                               : C:\lib\php\PEAR\tests
11. Name of configuration file                    : C:\lib\php\PEAR\pear.ini
12. Path to CLI php.exe                           : C:\lib\php

1-12, 'all' or Enter to continue:

I always place PEAR and all of it’s folders (data, cfg, www etc) under /PEAR folder under php root. Then the whole PEAR including it’s pear.ini configuration file and pear.bat is in one place. And then just add this ../PEAR folder to my system environment PATH variable. It is good idea to logout and login after this. Then pear.bat and other PEAR tools are available system-wide. There is no need to export environment variables into Windows registry after such install.

Then I immediately upgrade PEAR installation pear upgrade -all and install PHPUnit, DbUnit, PHPUnit_Selenium, CodeSniffer and MessDetector.

pear upgrade -all
pear config-set auto_discover 1
pear install -a pear.phpunit.de/PHPUnit
pear install -a phpunit/DbUnit
pear install -a phpunit/PHPUnit_Selenium
pear install -a PHP_CodeSniffer
pear channel-discover pear.phpmd.org
pear channel-discover pear.pdepend.org
pear install -a phpmd/PHP_PMD