PEAR:: Classes Worthy Of Attention

PEAR offers an excellent framework for re-usable PHP components. A wide range of PEAR classes is available, from XML Parsers to Captcha's and Mail components.

They're all easy to install, and have extensive documentation available so you can get started right away. Here's a list of some of the better, and probably lesser known ones.

  • PEAR::Mail
    PEAR's Mail package defines an interface for implementing mailers under the PEAR hierarchy. It also provides supporting functions useful to multiple mailer backends. Currently supported backends include: PHP's native mail() function, sendmail, and SMTP. This package also provides a RFC822 email address list validation utility class.
  • PEAR::XML_Parser
    This is an XML parser based on PHPs built-in xml extension. It supports two basic modes of operation: "func" and "event". In "func" mode, it will look for a function named after each element (xmltag_ELEMENT for start tags and xmltag_ELEMENT_ for end tags), and in "event" mode it uses a set of generic callbacks.
  • PEAR::MIME_Type
    Provide functionality for dealing with MIME types, such as auto-detecting MIME type on files.
  • PEAR::Net_Socket
    Net_Socket is a class interface to TCP sockets. It provides blocking and non-blocking operation, with different reading and writing modes (byte-wise, block-wise, line-wise and special formats like network byte-order ip addresses). It provides the base class for other popular PEAR-classes such as Net_SMTP and HTTP_Request.
  • PEAR::Archive_Tar
    This class provides handling of tar files in PHP.
    It supports creating, listing, extracting and adding to tar files. Gzip support is available if PHP has the zlib extension built-in or loaded. Bz2 compression is also supported with the bz2 extension loaded.

The list of available packages goes on for miles, and includes a Facebook package, a Number-to-Words convertor, Command line Argument Parser, CAPTCHA generator, Barcode Generator, ... Too much to mention!

For installation instructions, I'll refer you to the following two posts:

I'm interested to know what PEAR packages you're using, and why. Where do you draw the line between writing your own classes, and switching to PEAR's?

Looking for help?

Tired of fixing all these tech-problems yourself? We've got an excellent team at Nucleus, a top-class Belgian hosting provider, that can help you. Discover our Managed Hosting, where skilled engineers manage your servers and keep them up-to-date, so you can focus on your core business. We use a variety of Configuration Management Systems such as Puppet to make sure every config is reviewed, unit-tested and guaranteed to be working.

Want to get in touch? Find me as @mattiasgeniar on Twitter or via the contact-page on my blog.

Tagged with: ,
Posted in php
One comment on “PEAR:: Classes Worthy Of Attention
  1. Daniel says:

    If PEAR can do it, why reinvent the wheel?

    I use the following:

    Config
    HTML_BBCodeParser – BB code for all user input
    HTML_QuickForm – (and HTML_QuickForm_Renderer_Tableless) for form generation, it’s a bit dated and I’m waiting for HTML_QuickForm2 to progress further with development (poor support for renderers)
    HTML_TagCloud
    HTML_Template_IT
    HTTP_Upload
    MDB2 / MDB2_Driver_mysql
    Mail / Mail_Mime
    Pager
    Services_YouTube
    Validate
    XML_Serializer
    tidy

    My biggest complaint is only a few are E_STRICT compatible.

    It makes development so much easier. I’ve even adopted the package method for my own framework.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>