PEAR is the PHP Extension and Application Repository, a collection of open source classes that work
together. Developers can use PEAR classes to generate HTML, make SOAP requests, send MIME
mail, and a variety of other common tasks. A pear is also a tasty fruit.
To find general information on PEAR, read the PEAR manual; to discover the latest PEAR packages,
go to http://pear.php.net
. A summary of each week's happenings can be found at
Only a few core PEAR packages are bundled with the main PHP release. However, part of PEAR is a
program called, appropriately enough, pear, that makes it easy for you to download and install
additional PEAR packages. This program is also known as the PEAR package manager. Recipe 21.2
shows how to use the PEAR package manager.
PEAR packages divide into two major parts. One is the PHP Foundation Classes — object-oriented
code written in PHP that's high quality and usable in production environments on any platform and
web server. The other is PECL, or PHP Extension Code Library. PECL, pronounced pickle, is a series
of extensions to PHP written in C. These extensions are just like ones distributed with the main PHP
release, but they're of more specialized interest — such as an interface to the XMMS multimedia
player or the ImageMagick graphics library.
Additionally, the PEAR package manager allows you to use the PEAR class management
infrastructure with your personal projects. By creating your own packages that follow the PEAR
format, your users can use pear to download and install the files from your project's web site.
This chapter explains how to find a PEAR package you may want to use and how to install it on your
machine. Because PEAR has many classes, you need an easy way to browse them. Recipe 21.3
covers the different ways to find PEAR packages; once you've found a package's name, Recipe 21.4
shows how to view package details and information.
Once you locate a class you want to use, you need to run pear to transfer the class to your machine
and install it in the correct location on your server. Installing PEAR packages and PECL extensions
are the subjects of Recipe 21.5
and Recipe 21.6
, respectively. Recipe 21.7
shows how discover if
any upgrades are available to packages on your machine and how to install the latest versions. If
you want to remove a package, see Recipe 21.8
Finally, Recipe 21.9
describes how PEAR developers can write classes that abide by PEAR's coding
standards and how to document your class with PHPDoc.
PHP 4.3 includes the first stable release of PEAR. Earlier copies of PHP bundled versions of PEAR
prior to PEAR 1.0, but pear and the other packages weren't guaranteed to work, as they were still in
beta. If you are having problems using PEAR, you should remove any old files that may be
interfering with the release version. This includes the pear application itself; it can't always upgrade
itself to the latest release.