PEAR is a framework and distribution system for reusable PHP components. Actually, PEAR is a collection of add-on functionality for PHP development. There are many modules available to handle everything from session management to shopping cart functionality. Modules that are currently available are listed in Table 9-1.
Table 9-1. Pear modules
Tools & Utilities
Our list is not complete. Visit http://pear.php.net to find out all of the modules that are available for download.
PEAR uses a Package Manager to manage which PEAR features you install. Whether you need to install the Package Manager depends on which version of PHP you installed. If you're running PHP 4.3.0 or newer, it's already installed. If you're running PHP 5.0, PEAR has been split out into a separate package. The DB package that you're interested in is also installed by default with the Package Manager. So if you have the Package Manger, you're all set.
You can install the Package Manager on a Unix system by executing the following from the shell (command-line) prompt:
lynx -source http://go-pear.org/ | php
This takes the output of the go-pear.org site (which is actually the source PHP code) to install PEAR and passes it along to the php command for execution.
The PHP 5 installation includes the PEAR installation script as C:\php\go-pear.bat. In case you didn't install all the files in Chapter 2, go ahead and extract all the PHP files to C:/php from the command prompt, and execute the .bat file. Figure 9-5 shows the initial screen after executing the PEAR installer.
Figure 9-5. The go-pear.bat install script
You'll be asked a set of questions about paths. You can accept the defaults for all of them.
The php.exe file must be in your path. Verify by typing php.exe from a command prompt. If it is not found, you'll need to add it to your PATH variable. To access your system path, navigate to Start -> Control Panel -> System -> Environment and add an entry to the end of the path with C:\php.
The PEAR installer creates a file called C:\php\PEAR_ENV.reg. You need to double-click to set up the PEAR paths in the registry. This file is contingent on which PEAR version you installed. When the dialog box appears to verify your information, you will add this to the registry and click OK.
You may have to edit the php.ini file after running this .bat file to add the PEAR directory to the include path. Line 447 of php.ini now looks like this:
include_path = ".;c:\php\includes;c:\php\PEAR"
Apache must be restarted before the DB package can be used.
Please check back next week for the conclusion to this article.