PEAR is a framework and distribution system for reusable PHP packages. PEAR is made up of the following:
The PEAR Code Library
PEAR brings together many different open-source projects, each of which is bundled into its own package. Each PEAR package has its own maintainers and developers, who determine the changes and release cycle for their own packages, but the package structure is consistent for all PEAR projects.
You use the PEAR installer, which is shipped with PHP, to automatically download and install a PEAR package by simply giving its name. You will learn how to use the PEAR installer later in this lesson.
Each package may have dependencies from other PEAR packages, and this is explicitly noted in the documentation, even if packages appear to be related because of their names.
A package tree structure exists within PEAR, and an underscore character (_) separates nodes in the hierarchy. For instance, the HTTP package contains various HTTP utilities, whereas HTTP_Header deals specifically with HTTP header requests.
Package Distribution and Maintenance
PEAR packages are registered in a central database at http://pear.php.net. The PEAR website provides a searchable interface to the database by package name, category, and release date.
Maintainers of PEAR packages use the PEAR website to manage their projects. A CVS server allows developers to collaborate on source code and, once a release has been agreed upon, it can be made available from this central location immediately.
PEAR Coding Standards
The PCS documents were created because many different teams are developing open-source packages that might be of use to the PHP community.
The documents in PCS outline a structured way in which code should be written in order for a package to be accepted as part of the PEAR project. The standards are quite detailed and contain mostly points of style, such as identifier naming conventions and a consistent style to use when declaring functions and classes.
This may sound a little daunting, but as your scripts become more complicated, you will realize how important it is to write readable code, and you will begin to develop a clear coding style. The PCS documentation simply formalizes a set of guidelines for writing readable PHP.
You can find the PCS documents online at http://pear.php.net/manual/en/standards.php.
PHP Foundation Classes
PFC is a subset of PEAR packages, and these classes have a strict set of entrance criteria:
At the present time, only the PEAR installer is shipped with PHP. However, at a later date, certain classes may be included as standard. The PFC would be those classes.
Online Support for PEAR
The PEAR website, at http://pear.php.net, includes comprehensive online documentation for the PEAR project. The package database can be searched via the website, and package maintainers can log in to update their project details.
There are a number of mailing lists for PEAR users, maintainers, core developers, and webmasters. You can join any or all of these lists by using the form at http://pear.php.net/support/lists.php.