An Introduction to PEAR
Pages: 1, 2
Installing PHP from CVS
If you have never heard of CVS, take a look at the related documentation. It is not a difficult technology to use, but it takes a while to become comfortable with it.
Assuming you already have the standard CVS client installed correctly on your machine, you will need to follow these steps:
1. Open a terminal window (rxvt, xterm, or whatever)
2. Type the following commands:
cvs -z3 -d :pserver:firstname.lastname@example.org:/repository login [Enter
phpfi as the password here]
cvs -z3 -d :pserver:email@example.com:/repository co php4
[This will create a new directory named
cd php4 [Enter
cvs -z3 -d :pserver:firstname.lastname@example.org:/repository login
zend as the password here]
cvs -z3 -d :pserver:email@example.com:/repository co Zend TSRM
[This will create two new directories under "php4", named "Zend" and "TSRM"]
That was it. Running
buildconf should create the standard
configure script that can be used to set your options for PHP. In a normal installation, PEAR should be installed automatically under
/usr/local/lib/php, but you can still build the files manually by going into
php4/pear and running
make install-su as a superuser.
Besides that, you should add the PEAR root directory to the
include_path found in your
php.ini file. The default path should be
/usr/local/lib/php, but it may be elsewhere if you did some manual changes to your configure options.
Starting up with PEAR
PEAR packages can range from database abstraction layers to output cache systems, so PEAR is much more than a simple library -- it is a new standard of writing portable and clean PHP code. One of the most important things for a PEAR newcomer to do is to read the coding standards that are published in the PHP manual.
I'll give some tips on how to start working with PEAR::DB, because it is one of the most popular PEAR packages. You can get examples and help on how to use PEAR::DB by following these steps:
- Search MARC under PEAR-DEV or PEAR-GENERAL for answers to your questions.
- Read the unit-test scripts provided with the source code of PEAR. The location of these scripts can be found in the directory where your PHP CVS source is. In my case, it was
- Go through Tomas Cox's excellent PEAR::DB tutorial.
I hope this article has shed some light on the semi-mysterious PEAR library, and that it has provided you with some useful background information on one of the more promising developments in the PHP community.
Joao Prado Maia is a web developer living in Houston with more than four years of experience developing web-based applications and loves learning new technologies and programming languages.
Return to the PHP DevCenter.