Installing PEAR on Windows
I have been using phpDocumentor on my Windows laptop lately, and one of the requirements is to have PEAR installed. While this is a pretty simple process on Linux, it gets a little more complex on Windows.
Actually, it is not that complex. It is just difficult to find the proper resources (or at least it was for me).
I did find a number of posts / tutorials explaining the manual process of installing PEAR, but:
- It introduces possibilities of mishaps,
- I prefer when things are automated ;)
Automatically Install PEAR on Windows
First of all, I should specify that this was done on a Windows 10 Home x64 install with PHP 7.0.6. No WAMP, no MAMP, just PHP.
There are basically 2 steps required to install PEAR:
- Download the "installer"
- Run it
- Add the environment variables (yeah that's more than 2 steps, but this one is optional. Bonus!)
PHP.net provides a super handy
phar file that will allow you to install PEAR on your system in just one command line. Download go-pear.phar and save it in your PHP directory (most likely
The next step is to use
go-pear.phar to install PEAR. Simply open up a command prompt, move to your PHP directory, and type:
You should then be asked if you want to go for a local or system-wide install. I needed a system-wide install, so this entire tutorial is based on this scenario.
Now, just let the script do its job...
Unlike me, you should not be getting the message "WARNING! Old version found at C:\php [...]". I re-installed PEAR for the purpose of this tutorial, which is why I'm getting this warning.
Add the Environment Variables
As you can see at the end of the process, the script tells you:
For convenience, a REG file is available under C:\phpPEAR_ENV.reg. This file creates ENV variables for the current user.
If you go to
C:\php and double-click
PEAR_ENV.reg (a warning should appear, just click yes), the script will add all the required environment variables to your system.