jump to navigation

Installing PEAR Package Manager on Wamp2 in Ten Simple Steps December 16, 2011

Posted by Tournas Dimitrios in PHP.

PEAR is the abbreviation for “PHP Extension and Application Repository” and is pronounced just like the fruit . In short , the purpose of PEAR is to offer a library of open-source code for PHP users . The code in PEAR is partitioned in “packages”. Each package is a separate project with its own development team , version number, release cycle , documentation and a defined relation to other packages (including dependencies) . Packages are distributed as gzipped tar files with a description file inside , and installed on your local system using the PEAR installer (package-manager ) . The PEAR package manager allows you to access this library via a terminal (command line window)  an to install packages without having to worry about installing dependencies , placing files in particular locations , or tracking them down .   Linux admins are  familiar with the concept of installing/updating applications via the terminal , they will follow this article without any difficulties . Though , Windows user aren’t familiar with the terminal and may need to drink a cup of coffee before continuing reading .  If you know how to open a “terminal ” on your Windows machine then the following process is simple to follow , otherways drink two cups of coffee before continuing reading . Let us start ……

  • Step 1 : Open a terminal window and run a  ” php  -v ”  command . If the result is similar to the following picture , you are ready to go . ( Start ->All-Programs -> Accessories -> Command-Line )  .

    If previous step returned a ” php is not recognized as internal or external command ” ,  your computer’s environment variable must be configured with the absolute location of PHP’s exe file (php.exe)  . Right-click-My_computer_Icon -> properties -> Advanced -> Environment-variables and in the system-variables section locate the “Path” variable . Click on the “Path-variable” and “edit”  ->paste at the end of the string the absolute path of your PHP-exe . On my computer it is :   (  ;C:\Program Files\wamp\bin\php\php5.3.8 ) . Now repeat step-1 .

    Update 17-3-2013 : For Windows 7 or Vista …. one important step is to run the cmd (command-terminal) box in “Administrator” mode. To try this out , go to the run box and type in something (cmd , for example) . Now instead of hitting the Enter key , use Ctrl+Shift + Enter . You will be prompted with the  “User Account Control dialog” …. confirm by clicking the “YES” button ,  it will then open up a command prompt in Administrator mode . Run the cmd-terminal in “administrator-mode” , on each new package installation (for instance : pear install  package-Name)  .

  • Step 2 : Visit this link http://pear.php.net/go-pear.phar  and copy the file  into the same folder as php.exe .
    On my computer : C:\Program Files\wamp\bin\php\php5.3.8 . If you have multiple instances (versions ) of PHP installed on your wamp server , pay attention to select the proper PHP-version folder .
  • Step 3 : From the terminal run : php   go-pear.phar . Probably php 5.3 builds are not able to open the shipped go-pear.phar file . As a workaround, users can run the distributed phar with ” php -d phar.require_hash=0 go-pear.phar ” or download and use the old http://pear.php.net/go-pear non-pharred version . I prefer to use the newer .phar script . Users can also use : php -d phar.require_hash=0 go-pear.phar
  • Step 4 : Type “local” and confirm with “yes” .
  • Step 5 : Probably the suggested  directory locations for the PEAR  installation may be wrong , so we have to configure manually  the correct locations .  Type “all” and enter .
  • Step 6 : You have to go through twelve sequential steps on which each step demand the proper absolute path . The example below demonstrate my installation configurations .
  • Step 7 : The terminal will complete the installation . You will be asked to allow changes into  the php.ini file . (  I had to configure php.ini file  manually after the installation process ) .
  • Step 8 : Verify that PEAR manager is installed  , run “pear” in your terminal  . If you get a long list of PEAR-commands , congratulations you installation is completed .
  • Step 9 : Although on step-8 you where asked to allow changes to php.ini file , let’s verify that PEAR is  on your computer’s environment variable  . Create a new check_pear.php  file with the following contents :
    <?php require_once 'System.php'; var_dump(class_exists('System', false)); ?>

    If you access the file via your browser and get a ” Fatal error ” , just append the absolute path PHP’s exe file into php.ini’s  include_path directive
    include_path = “.;c:\php\includes;C:\my_php\library;C:\Program Files\wamp\bin\php\php5.3.8\pear”

  • Step 10 : Most used PEAR commands :  pear , pear list-all  , pear list -a  , pear search  package_name  , pear install package_name  .   Happy coding .

Some useful links :



1. Creating Tables with Pear’s HTML_Table Package « Tournas Dimitrios - December 20, 2011

[…] If you haven’t already setup your development environment , read my previous article “ Installing PEAR Package Manager on Wamp2 in Ten Simple Steps ” . Important to note is that you should already have a basic understanding of OOP consents […]

2. How to Debug PHP Code with Your Browser’s Console Tab « Tournas Dimitrios - September 7, 2012

[…] While previous method is simple to implement on a hosting environment , this example is tedious if you are not comfortable  with installing PEAR-packages . For starters , my previous article explains how to install PEAR-packages on WAMP in ten steps . […]

3. Boosting the Performance of a PHP-project with an Autoload Class Map | Tournas Dimitrios - April 15, 2013

[…] PEAR’s package manager is out of the scope of this article , follow the instructions given on this post , if you haven’t done already . phpab is a command line utility to automate the process of […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s