Sick of writing all your PHP? Why not use PEAR Libraries?

Do you still write all your PHP?

The PHP Extension and Application Repository (PEAR) can take a whole lot of hassle out of writing your own Web Applications. It really the best thing for a Web Developer since sliced bread.

Sliced bread is good because someone does the slicing for you and you know it's always going to fit in the toaster. This is what PEAR is all about. Unlike toast however, PEAR libraries can be used over and over again. Once you have it running on your Web Werver and you've configures your php.ini to include the PEAR Libraries you just reference in in your PHP files. You can use the PEAR manager to update your libraries too with go pear.

It's probably not worth your while to write a Database Abstraction Layer from scratch right? Just use the MDB2 package and it's ready to go. Same goes for basic User Authentication, Mail, Encryption and more. There are heaps of PEAR packages.

Here's an Example of the PEAR HTML Packages:

  1. HTML_AJAX PHP and JavaScript AJAX library
  2. HTML_BBCodeParser This is a parser to replace UBB style tags with their html equivalents.
  3. HTML_Common PEAR::HTML_Common is a base class for other HTML classes.
  4. HTML_Common2 Abstract base class for HTML classes (PHP5 port of HTML_Common package).
  5. HTML_Crypt Encrypts text which is later decoded using javascript on the client side
  6. HTML_CSS HTML_CSS is a class for generating CSS declarations.
  7. HTML_Form Simple HTML form package
  8. HTML_Javascript Provides an interface for creating simple JS scripts.
  9. HTML_Menu Generates HTML menus from multidimensional hashes.
  10. HTML_Page PEAR::HTML_Page is a base class for XHTML page generation.
  11. HTML_Page2 PEAR::HTML_Page2 is a base class for XHTML page generation.
  12. HTML_Progress How to include a loading bar in your XHTML documents quickly and easily.
  13. HTML_Progress2 How to include a loading bar in your XHTML documents quickly and easily.
  14. HTML_QuickForm The PEAR::HTML_QuickForm package provides methods for creating, validating, processing HTML forms.
  15. HTML_QuickForm2 PHP5 rewrite of HTML_QuickForm package

.
.
To get the PEAR Libraries running you'll need to install it on your Server. Here's a good article on sitepoint to get you going on Installing PEAR.

http://pear.php.net/




Wondering if frameworks are taking the place of PEAR (would PEAR be considered a framework?) - symphony and cake seem to add classes to handle most things that you might do in PEAR. Interested to see if people are actually starting to get into these frameworks, or a lot of people are still coding everything from scratch.

I don't know if PEAR is a framework. It's a rather broad term I guess. MODx even reckons it's a framework.

YEah symphony looks nice but I wonder also about how many people are into it.

Solar looks great but how many people support it?

I guess Ruby on Rails is taking off. So it's probably going to catch on

from the solar site

"However, with the exception of the base PEAR classes themselves (e.g. PEAR_Error), classes in PEAR are not intended to be a cohesive framework."

Seems to make sense.

I gotta say that the solar site puts me off - show me some shiny things that slide and i would be into it.

At least they are honest!

Have you used MODx?

nope - only framework i have used in production is drupal. they say that they are a framework/cms.

have played with ROR, and installed cake, but havent had the time to build anything with it.

Well I guess you're using a good one! Modx is more bells a whistles and buzzwords.

For me, I don't like it when I lose control over the front end and the CMS wants to write all the HTML and crap. That's why I didn't get into .NET (and some other reasons!)

Here's some pear help:

http://www.pear-forum.org/

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options