Most
PHP Web developers have heard of PEAR,
the PHP Extension and Application Repository, but very few of them actually use
it on a regular basis. This is an oversight that should be corrected, because
PEAR is actually a rich treasure trove of PHP widgets that can significantly
simplify the average Web developer’s workday.

If
you think I’m overstating the benefits, ask yourself if you’ve ever written
custom code to (a) create HTML e-mail,
(b) generate Web forms on the fly, or (c) validate email addresses. PEAR
has pre-built PHP packages for all these tasks, and a few hundred more besides.
These packages provide a robust, well-tested code base that can save you the
time and effort you would otherwise spend on “rolling your own” code.
You can’t beat the price either…they’re free!

PEAR
classes cover a wide range of tasks, and so this document will focus
specifically on classes of interest to developers working with Web pages and
form input. If there are other categories you’d like to see addressed, send in
your suggestions and we will examine those areas too…and until then, here’s
to easier coding!

Note: You can install
PEAR packages directly from the Web, by following the provided
instructions
.

Package Name

Description

URL

Validate

This
package provides validation routines for common input types: email addresses,
credit card numbers, URLs, dates and times, string and number classes, and
more.

Use this package to test user input entered in Web forms
and ensure it is valid before using it in a calculation/saving it to a file
or database.

http://pear.php.net/
package/Validate

Calendar

This
package creates calendar data structures for one or more months. These data
structures can then be combined with HTML formatting or a template to create
a calendar display, complete with forward/backward navigation links.

Use this package to quickly integrate a pop-up Web
calendar into a Web site.

http://pear.php.net/
package/Calendar

Mail_Mime

This
package provides routines to create a MIME-compliant multi-part message. Such
a message can contain embedded HTML, images, file attachments, or other
parts. The package also provides functions to decode received multi-part
messages into their constituent parts.

Use this package to create HTML email with embedded
images, or messages with one or more attachments. You can also use this class
to decode multi-part messages – for example, as an attachment browser in a
Web mail client.

http://pear.php.net/
package/Mail_Mime

Cache

This
package provides a simple caching framework for a Web site. It allows you to
cache the output of PHP scripts as well as function calls, and reduce
response times by rendering the cached pages to clients. Cached pages may be
stored as files on disk, in a database, or using a custom storage engine.

If your site receives a lot of traffic, use this package
to reduce server load and page processing time by occasionally providing
clients with snapshots from the page cache instead of the “live”
page. You can also reduce the load on your database server by caching the
output of frequently-used SQL queries.

http://pear.php.net/
package/Cache

Image_Graph

This
package makes it possible to automatically convert numerical data into a
graph suitable for display on a Web page. Bar, graph, pie, radar and scatter
graphs are just some of the supported graph types. X and Y axis
customizations are supported, as are many different output formats.

Use this package to display numerical data in a visual
manner for easier comprehension – for example, when calculating Web site
traffic or ad clicks

http://pear.php.net/
package/Image_Graph

HTML_QuickForm

This
package provides routines to generate, validate, and process Web forms
programmatically. It supports all the HTML form input types, and comes with
built-in validation routines for most common input types. It also provides
built-in functionality for multi-page forms and file upload forms.

Use this package to significantly simplify the task of
generating Web forms at run-time, or to efficiently validate and process form
input.

http://pear.php.net/
package/HTML_QuickForm

Auth

This
package provides a framework for a basic login/authentication system using
PHP. It can verify user credentials against a variety of data sources,
including MySQL databases, ASCII files, LDAP servers and POP3 servers.

Use this package to quickly create a login system for a
Web application. Because it has “out of the box” support for so
many authentication sources, it can also be used to implement Web-based
“single login” infrastructure.

http://pear.php.net/
package/Auth

XML_RSS

This
package is designed to parse RSS documents. It extracts information from an
RSS feed as PHP data structures, which can be processed and formatted for
display.

Use this package to integrate RSS feeds from other sites
into your Web pages.

http://pear.php.net/
package/XML_RSS

HTML_Progress

This
package provides a framework for a progress bar on a Web site. It uses PHP,
JavaScript and CSS to display and dynamically update a progress bar with
visual notification of a task’s progress.

Use this package to display progress bars for
time-consuming Web tasks
—for example a file upload or a
long-running loop.

http://pear.php.net/
package/HTML_Progress

Translation

This
package provides a framework for multi-lingual Web sites. It contains
routines to retrieve a translation for each string value from a database and
insert it into the appropriate location on each translation-enabled page.

Use this package to efficiently handle multi-language
versions of a Web site.

http://pear.php.net/
package/Translation/