Skip to content
Home » Web » PHP » How to Install PEAR in a WAMP

How to Install PEAR in a WAMP

PEAR could be the most important add-on library for PHP developers. Here is an example to install PEAR in a WampServer:

  1. Create a directory to serve PEAR.
  2. In this case, we choose C:\wamp\bin\php\pear for our PEAR.

  3. Download and save go-pear.phar from the official website.
  4. The file can be downloaded from http://pear.php.net/go-pear.phar

  5. Start cmd and cd to the directory that go-pear.phar resides in.
  6. C:\Documents and Settings\Administrator>cd C:\wamp\bin\php\pear
  7. Use php utility to execute the phar file.
  8. Start to install PEAR.

    C:\wamp\bin\php\pear>C:\wamp\bin\php\php5.4.3\php go-pear.phar

    Enter "local" and then "yes"

    Are you installing a system-wide PEAR or a local copy?
    (system|local) [system] : local
    Please confirm local copy by typing 'yes' : yes

    Only item 12 needs to be specified, please enter the path of php.exe.

    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\pear
     2. Temporary directory for processing            : C:\wamp\bin\php\pear\tmp
     3. Temporary directory for downloads             : C:\wamp\bin\php\pear\tmp
     4. Binaries directory                            : C:\wamp\bin\php\pear
     5. PHP code directory ($php_dir)                 : C:\wamp\bin\php\pear\pear
     6. Documentation directory                       : C:\wamp\bin\php\pear\docs
     7. Data directory                                : C:\wamp\bin\php\pear\data
     8. User-modifiable configuration files directory : C:\wamp\bin\php\pear\cfg
     9. Public Web Files directory                    : C:\wamp\bin\php\pear\www
    10. Tests directory                               : C:\wamp\bin\php\pear\tests
    11. Name of configuration file                    : C:\wamp\bin\php\pear\pear.ini
    12. Path to CLI php.exe                           :

    1-12, 'all' or Enter to continue: 12
    php.exe (sapi: cli) found.

    It will show 12 items again for you to confirm the path, this time, just press Enter to accept all. The installer will begin to install.

    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\pear
     2. Temporary directory for processing            : C:\wamp\bin\php\pear\tmp
     3. Temporary directory for downloads             : C:\wamp\bin\php\pear\tmp
     4. Binaries directory                            : C:\wamp\bin\php\pear
     5. PHP code directory ($php_dir)                 : C:\wamp\bin\php\pear\pear
     6. Documentation directory                       : C:\wamp\bin\php\pear\docs
     7. Data directory                                : C:\wamp\bin\php\pear\data
     8. User-modifiable configuration files directory : C:\wamp\bin\php\pear\cfg
     9. Public Web Files directory                    : C:\wamp\bin\php\pear\www
    10. Tests directory                               : C:\wamp\bin\php\pear\tests
    11. Name of configuration file                    : C:\wamp\bin\php\pear\pear.ini
    12. Path to CLI php.exe                           : C:\wamp\bin\php\php5.4.3

    1-12, 'all' or Enter to continue:
    Beginning install...
    Configuration written to C:\wamp\bin\php\pear\pear.ini...
    Initialized registry...
    Preparing to install...
    installing phar://C:/wamp/bin/php/pear/go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.7.tar...
    installing phar://C:/wamp/bin/php/pear/go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.3.0.tar..
    .
    installing phar://C:/wamp/bin/php/pear/go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.9.4.tar...
    installing phar://C:/wamp/bin/php/pear/go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.4.tar
    ...
    installing phar://C:/wamp/bin/php/pear/go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.2.1.tar...
    install ok: channel://pear.php.net/Archive_Tar-1.3.7
    install ok: channel://pear.php.net/Console_Getopt-1.3.0
    install ok: channel://pear.php.net/Structures_Graph-1.0.4
    install ok: channel://pear.php.net/XML_Util-1.2.1
    install ok: channel://pear.php.net/PEAR-1.9.4
    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\pear\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.

    PEAR will modify the interpreter php.ini in the following location. But for a WAMP server, the effective one is in C:\wamp\bin\apache\apache2.2.22\bin, you can append a snippet to apache\php.ini after the installer modifies the interpreter php.ini.

    Would you like to alter php.ini <C:\wamp\bin\php\php5.4.3\php.ini>? [Y/n] : Y

    php.ini <C:\wamp\bin\php\php5.4.3php.ini> include_path updated.

    Current include path           : .;C:\php\pear
    Configured directory           : C:\wamp\bin\php\pear\pear
    Currently used php.ini (guess) : C:\wamp\bin\php\php5.4.3\php.ini
    Press Enter to continue:

    ** WARNING! Old version found at C:\wamp\bin\php\pear, please remove it or be sure to use the new c:
    wamp\bin\php\pear\pear.bat command

    The 'pear' command is now at your service at c:\wamp\bin\php\pear\pear.bat

    ** The 'pear' command is not currently in your PATH, so you need to
    ** use 'c:\wamp\bin\php\pear\pear.bat' until you have added
    ** 'C:\wamp\bin\php\pear' 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!


    C:\wamp\bin\php\pear>
  9. Append a snippet to apache php.ini which is in C:\wamp\bin\apache\apache2.2.22\bin
  10. ;***** Added by go-pear
    include_path=".;C:\wamp\bin\php\pear\pear"
    ;*****
  11. C:\wamp\bin\php\pear should be added to PATH environmental variable.
  12. Restart the WAMP server

Now, let's test PEAR utility.

C:\Documents and Settings\Administrator>pear
Commands:
build                  Build an Extension From C Source
bundle                 Unpacks a Pecl Package
channel-add            Add a Channel
...
C:\Documents and Settings\Administrator>pear version
PEAR Version: 1.9.4
PHP Version: 5.4.3
Zend Engine Version: 2.4.0
Running on: Windows NT USER-JAUC9082P4 5.1 build 2600 (Windows XP Professional Service Pack 3) i586

C:\Documents and Settings\Administrator>pear config-get php_dir
C:\wamp\bin\php\pear\pear

C:\Documents and Settings\Administrator>pear info PEAR
ABOUT PEAR.PHP.NET/PEAR-1.9.4
=============================
Release Type           PEAR-style PHP-based Package
Name                   PEAR
Channel                pear.php.net
Summary                PEAR Base System
Description            The PEAR package contains:
                        * the PEAR installer, for creating,
...

Install a package MDB2.

C:\Documents and Settings\Administrator>pear install MDB2
downloading MDB2-2.4.1.tgz ...
Starting to download MDB2-2.4.1.tgz (119,790 bytes)
..........................done: 119,790 bytes
install ok: channel://pear.php.net/MDB2-2.4.1
MDB2: Optional feature fbsql available (Frontbase SQL driver for MDB2)
MDB2: Optional feature ibase available (Interbase/Firebird driver for MDB2)
MDB2: Optional feature mysql available (MySQL driver for MDB2)
...

C:\Documents and Settings\Administrator>pear info MDB2
ABOUT PEAR.PHP.NET/MDB2-2.4.1
=============================
Release Type              PEAR-style PHP-based Package
Name                      MDB2 (extends MDB)
Channel                   pear.php.net
Summary                   database abstraction layer
Description               PEAR MDB2 is a merge of the PEAR DB and Metabase
                          php database abstraction layers.
...

C:\Documents and Settings\Administrator>

Leave a Reply

Your email address will not be published. Required fields are marked *