How to install PHP PEAR and phploc on Windows
PEAR (short for PHP Extension and Application Repository) is a framework and distribution system for reusable PHP components. In includes many useful tools and components that can be easily downloaded and installed by using PEAR package manager. This post describes how to install and configure PEAR package manager and then how to use it to install a PEAR package. An example PEAR package used in this post is phploc, whichA is a tool for measuring the size of PHP projects.
Start by installing PHP on Windows by using one of the following methods:
- Install PHP for by using Web PI 3.0. With that you can install PHP for either IIS or WebMatrix or both;
- Download and unpack the PHPA 5.3A VC9A non-thread-safeA zip package and then register it with IIS by using PHP Manager.
Now open an elevated command line prompt and go to the directory where PHP was installed. For example if PHP 5.3 was installed with Web PI 3.0 then the directory path will be:
- %ProgramFiles%\PHP\v53\ - when PHP is installed for IIS
- %ProgramFiles%\IIS Express\PHP\v53 - when PHP is installed for IIS Express
While in that directory run the go-pear.bat command. If you intend on having multiple versions of PHP installed on the same machine then make sure to answer a€olocala€ť on the first question asked by go-pear.bat:
C:\Program Files\PHP\v5.3go-pear.bat Are you installing a system-wide PEAR or a local copy? (system|local) [system] : local Please confirm local copy by typing 'yes' : yes Below is a suggested file layout for your new PEAR installation.A To change individual locations, type the number in front of the directory.A Type 'all' to change all of them or simply press Enter to accept these locations. 1. Installation base ($prefix)A A A A A A A A A A A A A A A A A A : C:\Program Files\PHP\v5.3 2. Temporary directory for processingA A A A A A A A A A A : C:\Program Files\PHP\v5.3\tmp 3. Temporary directory for downloadsA A A A A A A A A A A A : C:\Program Files\PHP\v5.3\tmp 4. Binaries directoryA A A A A A A A A A A A A A A A A A A A A A A A A A A : C:\Program Files\PHP\v5.3 5. PHP code directory ($php_dir)A A A A A A A A A A A A A A A A : C:\Program Files\PHP\v5.3\pear 6. Documentation directoryA A A A A A A A A A A A A A A A A A A A A A : C:\Program Files\PHP\v5.3\docs 7. Data directoryA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A : C:\Program Files\PHP\v5.3\data 8. User-modifiable configuration files directory : C:\Program Files\PHP\v5.3\cfg 9. Public Web Files directoryA A A A A A A A A A A A A A A A A A A : C:\Program Files\PHP\v5.3\www 10. Tests directoryA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A : C:\Program Files\PHP\v5.3\tests 11. Name of configuration fileA A A A A A A A A A A A A A A A A A A : C:\Program Files\PHP\v5.3\pear.ini 12. Path to CLI php.exeA A A A A A A A A A A A A A A A A A A A A A A A A A : . 1-12, 'all' or Enter to continue:Continue following the prompts to complete the installation process. During the installation you may seeA a warning similar to the one shown below:
****************************************************************************** WARNING!A The include_path defined in the currently used php.ini does not contain the PEAR PHP directory you just specified: If the specified directory is also not in the include_path used by your scripts, you will have problems getting any PEAR packages working. Would you like to alter php.ini ? [Y/n] : yMake sure to say yes [y]A to the question about altering php.ini so that include_path directive is updated to the correct PEAR PHP directorty
After that you may also get a warning about out-of-date version of PEAR package manager:
** WARNING! Old version found at C:\Program Files\PHP\v5.3, please remove it or be sure to use the new c:\program files\php\v5.3\pear.bat commandIf you see that then after the go-pear.bat has finished its work, run the following command to upgrade the PEAR package manager:
C:\Program Files\PHP\v5.3pear upgrade pear downloading PEAR-1.9.1.tgz ... Starting to download PEAR-1.9.1.tgz (293,587 bytes) .................done: 293,587 bytes downloading Archive_Tar-1.3.7.tgz ... Starting to download Archive_Tar-1.3.7.tgz (17,610 bytes) ...done: 17,610 bytes downloading Structures_Graph-1.0.4.tgz ... Starting to download Structures_Graph-1.0.4.tTruncated by Planet PHP, read more at the original (another 2827 bytes)


