The PHP Extension and Application Repository (PEAR; pronounced just like the fruit) is a set of reusable PHP classes and a distribution system through which end users can acquire those classes for use in their PHP applications. Because these are open source classes, you can (by and large) freely use the code for whatever purpose you want so long as you do not claim you wrote it, fail to give due credit, or use trademarked names in your advertising.
On the PEAR home page (http://pear.php.net), you can learn more about PEAR, browse available classes, and view documentation. The following subsections examine some significant features of PEAR.
Library of Code
PEAR is a library of PHP code, typically organized into classes. The code and classes are partitioned into packages, which users can browse and download to their machines. Packages are organized into a tree, with nodes representing a part of the package name.
Sample PEAR packages include the DB package, which abstracts data access on top of many database servers; mathematics components to help with complex mathematical operations; and the Date package, which allows for a powerful and flexible representation of dates and times.
Each package has a status indicating whether it is a snapshot, devel (still in development), alpha, beta, or stable package. All packages show the available versions, their constituent components, and reported bugs. To ensure that all classes are legible, of basic quality, and debuggable, packages added to PEAR must conform to strict coding standards established by PEAR maintainers.
PEAR Foundation Classes
The PEAR foundation classes (PFC) are core classes of high quality and are broadly reusable and interoperable. Only classes marked as stable can be included in this collection of classes, and classes must be reasonably general. A class that computes 47-bit hashes only when running on certain processors in northern Idaho is of limited use, for example, and would not be considered a candidate for inclusion.
Note that PFC is not quite yet an entity as much as a concept. It is best currently considered a set of broadly reusable classes in PHP that are stable. As future versions of the core PHP software look at including some of the PEAR classes, PFC is what would be included.
PEAR has a large support community, anchored by the http://pear.php.net web site. In addition to the online documentation, bug databases, and version information for the individual packages, there are many PEAR mailing lists. Specific ones exist for users, package authors, documentation writers, quality assurance people, and so on.
A number of tutorials are also available, and you can find discussions about how to use PEAR and its various packages and how to write your own packages for public consumption.
You can find more information about all of this at http://pear.php.net/support.
Another feature, the PHP Extension Community Library (PECL; pronounced "pickle"), is a set of extensions for PHP written in C/C++. This library used to be a subcategory of PEAR, but it has since been moved into its own project, which you can visit at http://pecl.php.net. There are PECL extensions for many different feature areas, such as supporting new types (such as large integers), more database classes, and image-manipulation packages.
PECL is beyond the scope of this book, but it is mentioned here so that you are familiar with what it is when you encounter it on the PEAR web site.