Installing a PEAR package is a surprisingly automated process, accomplished simply by executing the install command. The general syntax follows:
%>pear install [options] package
Suppose for example that you want to install theAuthpackage. The command and corresponding output follows:
%>pear install Auth
-------------------------------------------- Did not download dependencies: pear/File_Passwd, pear/Net_POP3, pear/MDB,pear/MDB2, pear/Auth_RADIUS, pear/Crypt_CHAP,pear/File_SMBPasswd, use --alldeps or --onlyreqdeps to download automatically pear/Auth can optionally use package "pear/File_Passwd" (version >= 0.9.5) pear/Auth can optionally use package "pear/Net_POP3" (version >= 1.3) pear/Auth can optionally use package "pear/MDB" pear/Auth can optionally use package "pear/MDB2" (version >= 2.0.0RC1) pear/Auth can optionally use package "pear/Auth_RADIUS" pear/Auth can optionally use package "pear/Crypt_CHAP" (version >= 1.0.0) pear/Auth can optionally use package "pear/File_SMBPasswd" pear/Auth can optionally use PHP extension "imap" pear/Auth can optionally use PHP extension "vpopmail" downloading Auth-1.3.0.tgz ... Starting to download Auth-1.3.0.tgz (39,759 bytes) ..........done: 39,759 bytes install ok: channel://pear.php.net/Auth-1.3.0 --------------------------------------------
As you can see from this example, many packages also present a list of optional dependencies that if installed will expand the available features. For example, installing theFile_SMBPasswdpackage enhances Auth’s capabilities, enabling it to authenticate against a Samba server. Enabling PHP’s IMAP extension allowsAuthto authenticate against an IMAP server.
Assuming a successful installation, you’re ready to begin using the package.
Automatically Installing All Dependencies
Later versions of PEAR will install any required package dependencies by default. However you might also wish to install optional dependencies. To do so, pass along the-a(or--alldeps) option:
%>pear install -a Auth_HTTP
Manually Installing a Package from the PEAR Web Site
By default, the PEAR Package Manager installs the latest stable package version. But what if you were interested in installing a previous package release, or were unable to use the Package Manager altogether due to administration restrictions placed on a shared server? Navigate to the PEAR Web site athttp://pear.php.net/and locate the desired package. If you know the package name, you can take a shortcut by entering the package name at the conclusion of the URL:http://pear.php.net/ package/.
Next, click the Download tab found toward the top of the package’s home page. Doing so produces a linked list of the current package and all previous packages released. Select and download the appropriate package to your server. These packages are stored in TGZ (tar and Gzip) format.
Next, extract the files to an appropriate location. It doesn’t really matter where, although in most cases you should be consistent and place all packages in the same tree. If you’re taking this installation route because of the need to install a previous version, it makes sense to place the files in their appropriate location within the PEAR directory structure found in the PHP root installation directory. If you’re forced to take this route in order to circumvent ISP restrictions, creating a PEAR directory in your home directory will suffice. Regardless, be sure this directory is in theinclude_path.
The package should now be ready for use, so move on to the next section to learn how this is accomplished.