CHAPTER 10 – OBTAINING PEAR
In this section, you learn how to install PEAR on your platform from a PHP distribution or through the go-pear.org web site.
Installing with UNIX / Linux PHP Distribution This section describes PEAR installation and basic usage that is specific for UNIX or UNIX-like platforms, such as Linux and Darwin. The installation of the PEAR Installer itself is somewhat OS-dependent, and because most of what you need to know about installation is OS-specific, you find that here. Using the installer is more similar on different platforms, so that is described in the next section, with the occasional note about OS idiosyncrasies. As of PHP 4.3.0, PEAR with all its basic prerequisites is installed by default when you install PHP. If you build PHP from source, these configure options cause problems for PEAR: --disable-pear. make install will neither install the PEAR installer or any packages. --disable-cli. The PEAR Installer depends on a standalone version of PHP installed. --without-xml. PEAR requires the XML extension for parsing package information files.
Windows This section shows how to install PEAR on a Windows PHP installation. Start by just installing a binary distribution of PHP from http://www.php.net/downloads.php (see Figure 10.1). If you go with the defaults, your PHP install will end up in C:PHP, which is what you will see in the forthcoming examples. Fig. 10.1 PHP Welcome screen.
Installing with PHP Windows Installer When you have PHP installed, you need to make sure that your include_path PHP setting is sensible. Some versions of the Windows PHP Installer use c:php4pear in the default include path, but this directory (c:php4) is differ- ent from the one created by the PHP Windows Installer. So, edit your php.ini file (in c:winnt or c:windows, depending on your Windows version) and change this directory to c:phppear (see Figure 10.2). Fig. 10.2 Example php.ini modifications Now, you are ready to use go-pear.
go-pear.org go-pear.org is a web site with a single PHP script that you can download and run to install the latest stable version of the PEAR Installer and the PHP Foundation Classes (PFC). go-pear is cross-platform and can be run from the command line and from your web server. PHP distributions bundle a particular release of the PEAR Installer; on the other hand, go-pear gives you the newest stable PEAR releases. However, go-pear does know your directory layout, but really contorts itself to figure it out, and will try adapting your PEAR Installation to that. In this section, you learn how to use go-pear from the command line and web server, and on UNIX and Windows.
Prerequisites Because go-pear is written in PHP, you need a CGI or CLI version of PHP to execute it outside the web server. By default, the CLI version is installed along with your web server PHP module. Try running php v to see if it is available to you: PHP 5.0.0 (cli), Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0, Copyright (c) 1998-2004 Zend Technologies By default, the php command is installed in the /usr/local/bin directory on UNIX, or c:php on Windows. In Windows, the CLI version of PHP may also be called php-cli; in that case, you need to type php-cli for every example that says just php.