In this tutorial I will explain step by step how to install PEAR [1] and some of its packages in Windows with
wampserver [2].
1. Download and install the latest version of the WAMP Server. This is the Windows AMP (Apache, MySQL & PHP) package that I use, but I do not doubt that the results will be equally satisfactory if you use another one, like XAMPP [3] for example.
2. During the installation, I used the default paths proposed the installer: "C:\wamp", "C:\wamp\www", etc. Although these paths will be referenced in this tutorial, feel free to alter the paths to your needs.
3. Enter "C:\wamp\php", and locate and execute the file "go-pear.bat".
C:\Documents and Settings>cd ..
C:\>cd wamp\bin
C:\wamp\bin>cd php\php5.2.5
C:\wamp\bin\php\php5.2.5>go-pear.bat
Are you installing a system-wide PEAR or a local copy?
(system|local) [system] : 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:\wamp\bin\php\php5.2.5
2. Temporary directory for processing : C:\wamp\bin\php\php5.2.5\tmp
3. Temporary directory for downloads : C:\wamp\bin\php\php5.2.5\tmp
4. Binaries directory : C:\wamp\bin\php\php5.2.5
5. PHP code directory ($php_dir) : C:\wamp\bin\php\php5.2.5\pear
6. Documentation directory : C:\wamp\bin\php\php5.2.5\pear\docs
7. Data directory : C:\wamp\bin\php\php5.2.5\pear\data
8. Tests directory : C:\wamp\bin\php\php5.2.5\pear\tests
9. Name of configuration file : C:\WINDOWS\pear.ini
10. Path to CLI php.exe : C:\wamp\bin\php\php5.2.5\.
1-10, 'all' or Enter to continue:
Beginning install...
Configuration written to C:\WINDOWS\pear.ini...
Initialized registry...
Preparing to install...
installing
phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.2.tar...
installing
phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.3.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.6.1.tar...
installing
phar://go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.2.tar.
..
pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
install ok: channel://pear.php.net/Archive_Tar-1.3.2
install ok: channel://pear.php.net/Console_Getopt-1.2.3
install ok: channel://pear.php.net/Structures_Graph-1.0.2
install ok: channel://pear.php.net/PEAR-1.6.1
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based
installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based
installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"
******************************************************************************
WARNING! The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
<C:\wamp\bin\php\php5.2.5\pear>
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 <C:\wamp\bin\php\php5.2.5\php.ini>? [Y/n] :
y
php.ini <C:\wamp\bin\php\php5.2.5\php.ini> include_path updated.
Current include path : .;C:\php5\pear
Configured directory : C:\wamp\bin\php\php5.2.5\pear
Currently used php.ini (guess) : C:\wamp\bin\php\php5.2.5\php.ini
Press Enter to continue:
** WARNING! Old version found at C:\wamp\bin\php\php5.2.5, please remove it
or b
e sure to use the new c:\wamp\bin\php\php5.2.5\pear.bat command
The 'pear' command is now at your service at
c:\wamp\bin\php\php5.2.5\pear.bat
** The 'pear' command is not currently in your PATH, so you need to
** use 'c:\wamp\bin\php\php5.2.5\pear.bat' until you have added
** 'C:\wamp\bin\php\php5.2.5' to your PATH environment variable.
Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.
For more information about PEAR, see:
http://pear.php.net/faq.php
http://pear.php.net/manual/
Thanks for using go-pear!
* WINDOWS ENVIRONMENT VARIABLES *
For convenience, a REG file is available under
C:\wamp\bin\php\php5.2.5\PEAR_ENV
.reg .
This file creates ENV variables for the current user.
Double-click this file to add it to the current user registry.
Press any key to continue . . .
C:\wamp\bin\php\php5.2.5>
4. A command prompt window will be opened with the following message; press Enter to proceed.
5. Afterward, a list of up to 10 (this length may differ on XAMPP and others) filesystem locations will be displayed. Once again press Enter.
6. Then it will ask if we want to modify php.ini; Type in the letter "Y" (in capital letters) and press Enter.
7. To view this modification check the end of the "php.ini" (located in "C:\wamp\php") and you should see:
;***** Added by go-pear include_path=".;C:\wamp\php\pear" ;*****
8. Next you will be notified that the include_path was updated. Press Enter to continue.
9. A final message announces that a file called PEAR_ENV.reg has been created, which, upon execution, will add some Windows environment variables.
10. Enter "C:\wamp\php" and double click the file called "PEAR_ENV.reg". When asked to confirm the addition of registry values choose "Yes" and then click "OK".
11. In "C:\wamp\php", copy the file pear.bat to "C:\WINDOWS\system32". Alternatively you can add "C:\wamp\php" to your windows PATH environment variable to expose this file globally.
12. Next open the run dialog and type "cmd" to open a command prompt window.
13. Type pear to see all available commands and verify proper installation. If this command is unrecognized you will have to review the previous steps and repeat anything you missed.
14. Next update the memory_limit property value to 64M in php.ini. This will help php script execution. This file is found in
"C:\wamp\php\php.ini" and "C:\wamp\Apache2\bin\php.ini"; update both.
15. Now reinitiate the services/processes through WAMP.
Whenever you update PEAR or some of its packages, copy pear.bat into system32 to update our list of PEAR commands. This extra step can be avoided if the path to pear.bat has been added to your PATH environment variable.
So you can see the only thing to get excited about is the prospect of using the PEAR library in you PHP applications. Something which is going to become more and more common. I hope that PHP6 will acquire a built in installer for PEAR.
Happy Publishing!












