PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Getting PEAR Working On Windows 7

Note: This article was originally published at Planet PHP on 10 May 2012.
Planet PHP

So that I don't forget how to do this next time around. Worked for me, your mileage may vary.

First step is to get a working install of PHP.

  1. Download PHP 5.4.latest ZIP file from the PHP Windows website
  2. Unpack the ZIP file into c:\php. You should end up with c:\php\php.exe
  3. Copy c:\php\php.ini-development to be c:\php\php.ini
  4. Edit c:\php\php.ini to suit (e.g. set date.timezone)
  5. Make sure you add c:\php to your system PATH (via Computer's Advanced Properties - Environment Variables)
  6. Reboot (this is Windows, after all :)

At this point, you should be able to open up a Command Prompt, and type aphp -v', and see the response aPHP v5.4.latest a' appear as expected.

Now for PEAR itself.

  1. Open http://pear.php.net/go-pear.phar in a browser, save this file into c:\php
  2. In a Command Prompt, cd to c:\php and then run aophp c:\php\go-pear.phara
  3. At the prompt, select asystem'. A text menu of paths will appear
  4. Fix the default path for pear.ini (option 11) to be c:\php\pear.ini
  5. Fix the default folder to look inside for php.exe to be c:\php
  6. Make sure the binaries folder (option 4) is c:\php
  7. Check all of the other options, make sure they are prefixed with c:\php
  8. Press ENTER, and you should see PEAR downloading various PEAR packages onto your system
  9. Double-click the PEAR_ENV.reg file in c:\php
  10. Reboot again to make sure PEAR_ENV registry entries have taken effect

At this point, PEAR is installed and should be available to use in your own projects, or with something like Phix.

Personal Notes

Some reminders to myself for the next time I have to do this.

  • Documentation for PHP for Windows and PEAR for Windows both seem to be out of step with current downloads. There's currently no Windows installer for PHP available, and the PHP .ZIP file doesn't contain the ago-pear.bat' file.
  • You have to pay close attention to the default folders offered when running ago-pear.phar'. They appear to use the current working directory as the prefix even when installing system-wide, except for the location of pear.ini and php.exe - neither of these defaults are sane, and must be manually changed during the install :(
  • After install, pear command doesn't seem to be 100% compatible with its behaviour on Linux and OS X. -D switch didn't work, there may be other problems too that I haven't yet found.
  • Both reboots are required - I'm not taking the piss there - for all running Windows apps to pick up the changes.