Introducing PEAR

PEAR is a framework and distribution system for reusable PHP packages. PEAR is made up of the following:

  • A structured library of open-source code for PHP developers

  • A system for distributing and maintaining code in packages

  • The PEAR Coding Standards (PCS)

  • The PHP Foundation Classes (PFC)

  • Online support for the PEAR community through a website and mailing list

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

PHP Foundation Classes

PFC is a subset of PEAR packages, and these classes have a strict set of entrance criteria:

  • Quality Packages must be in a stable state.

  • Generality Packages should not be excessively specific to any particular type of environment.

  • Interoperability Packages should work well with other packages and in different environments, and they should have a standardized API.

  • Compatibility Packages must be designed to be backward compatible when new features are added.

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, 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

    Sams Teach Yourself PHP in 10 Minutes
    Sams Teach Yourself PHP in 10 Minutes
    ISBN: 0672327627
    EAN: 2147483647
    Year: 2005
    Pages: 151
    Authors: Chris Newman

    Similar book on Amazon © 2008-2017.
    If you may any questions please contact us: