There are many good reasons for following the PEAR coding standards which I don’t have time to go into now, a slightly elabourated version of the ‘rules’ is available here, mostly borrowed from the Horde project.

But by far the most convincing reason to use the file naming convention, which means that a class located in your include path like Foo/Bar/Baz.php is called Foo_Bar_Baz, is the ability to take advantage of PHP 5’s __autoload magic method.

What this means is that if you instantiate the above class, and forgot to require it, it can be located and loaded automatically, from any of hundreds of classes in your include path. Here’s the code:

Our man Greg
Beaver has been working overtime getting the latest
version of the PEAR
package manager ready. He also has a blog which is a great
way to keep uptodate with all the latest PEAR package mgr
news. Some recent entries include:

If you really want to know everything that’s gone on with the package manager, you can read through the posts at http://news.php.net/php.pear.core.
And if you’ve read all this and you’re wonder "why is this guy always
going on about PEAR package mgr" (as indicated by the poll in the
bottom left corner 😉 then just keep in mind some of the following:

one of the keys to the success of the Linux platform is tools like RPM, apt-get and more recently yum

one of the pillars of Redhat’s success is the RHN or Redhat Network

package management has a long history with other languages and a well-trodden track record with, eg, CPAN.

Thanks go out to Wolfram Kriesing for having put together the following tutorial for the excellent PEAR::Tree package.

For those of you who don’t know, PEAR::Tree is a package that provides methods to read and manipulate trees, which are stored in the DB or an XML file. The trees can be stored in the DB either as nested trees. Or as simple trees, which use parentId-like structure. Currently XML data can only be read from a file and accessed. The package offers a large number of methods to access and manipulate trees. For example methods like: getRoot, getChild[ren], getParent, getPath and many more.

To get up and running you will need to download the package from the PEAR site. Here are the API docs to get you started.

UPDATE: there are a number of sites linking to this page, I’m afraid a link to the cited tutorial is no longer available as the original author removed it.