///5 PEAR gems: free php scripts that will help you code quicker

5 PEAR gems: free php scripts that will help you code quicker

PEAR, the PHP Extension and Application Repository, contains hundreds of freely available packages that can be reused in your application. Packages usually come with various functionality within one or more classes, and the PEAR coding standards make sure packages follow the same general style for ease of implementation. Best of all; they’re all entirely open source, from MIT to GPL.

However, many of these packages are bloated, slow and full of specialised features that you may never want to use. Sifting through the repository is also a challenge; a basic category system is in place, but it’s hard to tell what you want when you don’t know what’s available. Here are some gems from the PEAR repository that you could really find useful.

1. Services_Akismet: Deal with spam once and for all
When it comes to dealing with comment spam, you can’t go past Akismet. It powers just about every WordPress blog out there, including this one; it also has an API web service that allow it to be used in any other web application, and Services_Akismet takes advantage of this. Best of all, it’s free for personal or commercial use.

2. HTTP_Request: Perform complex HTTP requests
Sure, there are many web services to hook into and web pages to download, but how do you access them all? Some times you need to go a little beyond basic file_get_contents; make HTTP requests with sessions attached, upload files, do some basic authentication, maybe even work with a proxy. HTTP_Request will help you do all this and more in a matter of a few lines of code.

3. Archive_Tar
When maintaining a big web application, you’ll often find your server filling up with cache files, archives and data dumps. Storing these effectively is very important to maintaining the performance of your server; if you don’t access them frequently, the best way to achieve this is with Archive_Tar. Similar to creating a .tar tarball and compressing it with GZip on your machine, Archive_Tar will allow your web server to compress large files quickly and effectively.

4. Spreadsheet_Excel_Writer
When creating MS Office files programmaticaly, you often have to rely on having a Windows server with the actual Office products installed to generate your files. However, COM isn’t the best approach if performance is a concern, and more often than not you’ll be deploying on a Windows server. If you need to generate Excel files, no matter what platform you’re working with, Spreadsheet_Excel_Writer is your best bet for pure PHP.

5. XML_Parser
XML is becoming more and more prominent in web applications. From configuration files to meta information and even page data. XML_Parser provides a consistent, reliable, effective way to parse XML files, and is reasonably fast as well.

Have a look through these PEAR packages; remember you can easily install them just by running `pear install PACKAGE_NAME` at a command line/terminal. If this isn’t an option, you can still download them and include them as usual (although you may need to slightly rewrite file paths within the PEAR packages, as they include each other).

2008-03-19T04:30:01+00:00 March 19th, 2008|PHP|2 Comments

About the Author:


  1. Web Proxy March 25, 2009 at 8:16 AM

    You made some good points there. I did a search on the topic and found most people will agree with your blog.

  2. ScriptoManiac December 5, 2009 at 5:25 AM

    Nice post..Keep them coming :) Thanks for sharing.

Leave A Comment