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:

  1. It introduces possibilities of mishaps,
  2. 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:

  1. Download the “installer”
  2. Run it
  3. Add the environment variables (yeah that’s more than 2 steps, but this one is optional. Bonus!)

Download go-pear.phar

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 C:\php).

Run go-pear.phar

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:

php go-pear.phar

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.

Windows Environment Variables

Windows Environment Variables