PLib basics




The basic idea of PLib is that we have namespaces, modules, classes and functions. Of course the namespace is not a real namespace in the real sence of the word in programmatical terms - although real namespaces is available in PHP since version 5.3.0 it will take some time before that version is commonly used since it's quite new as this is written.

We can say that a PLib namespace is the name of a directory whithin the root of PLib. A module is the name of a PHP file whithin a namespace. And obviously classes and functions is the PHP stuff written in the module.

For example there's a directory in PLib named Web which then is a PLib namespace. Whithin this directory there's a couple of PHP files, for instance RSS.php, which then is a PLib module. RSS.php contains a couple of classes and is called nothing else than PLib classes.

Installing PLib

The first thing you need to do when using PLib, other than download it, is to put the root directory of PLib somewhere in your file system. PLib can recide anywhere and does not have to be put in your public web path. So just put the directory plib anywhere in your filesystem.

It's hard to say what version of PHP is needed since that depends on what modules you whish to use. One thing is certain though: You'll need at least version 5 of PHP. Some modules depends on PHP 5.2 or newer. Some modules depend on specific PHP extension. Not too surprisingly the IMAP module needs the PHP Imap extension to work. So the only way to tell if PLib will work out for you is trying it out.

There is one directories that needs to be writable for PLib to work correctly and fully:

The PLib temporary directory

A few modules need to save stuff to the disk to function properly. Examples are the cacheing module and the HTTP client module. For those to function properly PLib needs to be aware of a writable directory. By default PLib will check to see if the tmp directory in the root of PLib is writable and if not an exception will be thrown.

If you don't whish to use the default tmp directory you can override this by defining the constant PLIB_TMP_DIR prior to including PLib.php

Next: Using PLib »