Skip to content

How to Install PEAR in a WAMP

  • by
PEAR could be the most important add-on library for PHP developers. Here is an example to install PEAR in a wamp server:
  1. Create a directory to serve PEAR.
  2. In this case, we choose C:wampbinphppear 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:wampbinphppear
  7. Use php utility to execute the phar file.
  8. Start to install PEAR.
    C:wampbinphppear>C:wampbinphpphp5.4.3php 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:wampbinphppear
     2. Temporary directory for processing            : C:wampbinphppeartmp
     3. Temporary directory for downloads             : C:wampbinphppeartmp
     4. Binaries directory                            : C:wampbinphppear
     5. PHP code directory ($php_dir)                 : C:wampbinphppearpear
     6. Documentation directory                       : C:wampbinphppeardocs
     7. Data directory                                : C:wampbinphppeardata
     8. User-modifiable configuration files directory : C:wampbinphppearcfg
     9. Public Web Files directory                    : C:wampbinphppearwww
    10. Tests directory                               : C:wampbinphppeartests
    11. Name of configuration file                    : C:wampbinphppearpear.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:wampbinphppear
     2. Temporary directory for processing            : C:wampbinphppeartmp
     3. Temporary directory for downloads             : C:wampbinphppeartmp
     4. Binaries directory                            : C:wampbinphppear
     5. PHP code directory ($php_dir)                 : C:wampbinphppearpear
     6. Documentation directory                       : C:wampbinphppeardocs
     7. Data directory                                : C:wampbinphppeardata
     8. User-modifiable configuration files directory : C:wampbinphppearcfg
     9. Public Web Files directory                    : C:wampbinphppearwww
    10. Tests directory                               : C:wampbinphppeartests
    11. Name of configuration file                    : C:wampbinphppearpear.ini
    12. Path to CLI php.exe                           : C:wampbinphpphp5.4.3

    1-12, 'all' or Enter to continue:
    Beginning install...
    Configuration written to C:wampbinphppearpear.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:wampbinphppearpear>
    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 intepreter php.ini in the following location. But for a wamp server, the effective one is in C:wampbinapacheapache2.2.22bin, you can append a snippet to apache php.ini after the installer modifies the intepreter php.ini.
    Would you like to alter php.ini <C:wampbinphpphp5.4.3php.ini>? [Y/n] : Y

    php.ini <C:wampbinphpphp5.4.3php.ini> include_path updated.

    Current include path           : .;C:phppear
    Configured directory           : C:wampbinphppearpear
    Currently used php.ini (guess) : C:wampbinphpphp5.4.3php.ini
    Press Enter to continue:

    ** WARNING! Old version found at C:wampbinphppear, please remove it or be sure to use the new c:
    wampbinphppearpear.bat command

    The 'pear' command is now at your service at c:wampbinphppearpear.bat

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

  9. Append a snippet to apache php.ini which is in C:wampbinapacheapache2.2.22bin
  10. ;***** Added by go-pear
    include_path=".;C:wampbinphppearpear"
    ;*****

  11. Add C:wampbinphppear 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:wampbinphppearpear

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>
Tags:

Leave a Reply

Your email address will not be published.