The PEAR Package Tour: PEAR Basics - Installing PEAR Modules
(Page 2 of 5 )
Base Installer
To start off with PEAR, you need to have the basic PEAR installation on your system. With a modern version of PHP, those after 4.3.0, PEAR comes with PHP unless it is explicitly excluded at compile time with the --without-pear flag.
On a Windows system, you may have to complete an additional step after PHP is installed. You’ll need to add the location of the PEAR installer to your command path. This is most easily accomplished by double clicking PEAR_ENV.reg in your PHP installation directory. This is a small registry entry that will add PEAR to your path. You can verify this step by opening the command-line and attempting to run the PEAR installer:
C:> pear
Commands
build Builds an Extension from C source
bundle Unpacks a Pecl Package
channel-add Add a channel
…
You should get a list of commands for the installer, and not an error telling you that “pear” is not a recognized internal or external command.
On Linux or Mac OSX, pear should be installed and ready to go. You may want to update your PEAR system. You can determine what version you have installed with:
> pear version
PEAR Version: 1.4.3
…
If your version is outdated, download and run the updater http://pear.php.net/go-pear. Just save it as go-pear.php and then run it with the PHP command line.
> php go-pear.php
You will be prompted to answer some questions, and in most cases, the defaults will work fine.
If you are on a shared host, where you do not have command line access, you can copy go-pear.php into a web accessible directory and load it in your browser. A web-based installer will guide you through installing a copy of PEAR for use in your personal web space.
Finally, you’ll need to ensure that the PEAR directories are in your PHP include path. First, find out what path PEAR is configured to use.
> pear config-get php_dir
/usr/share/php
Now, check your PHP include path. A simple way to do this is to create a .php file in your web directories and include the phpinfo() command:
<?php
phpinfo();
?>
When loaded in a browser, this will display all sorts of useful information about your PHP set-up. Search for the include_path variable in the Configuration section, and verify that the PEAR directory is included.
If this is not the case, you’ll need to edit your php.ini file. In the same phpinfo() output, there is a “Loaded Configuration File” variable near the top. You’ll want to edit this file and add your PEAR directory to the include_path. The result should look something like this:
include_path = ".:/usr/share/php"
If you modify php.ini, you’ll need to restart the web server.
Next: Installing Packages >>
More PEAR Articles Articles
More By Chris Moyer