Page 485 - Beginning PHP 5.3
P. 485
Chapter 15: Making Your Job Easier with PEAR
The PEAR packages are usually installed in folders in your PEAR path:
❑ /usr/share/php if you ’ re running Ubuntu
❑ C:\wamp\bin\php\php5.2.6\PEAR or similar if you ’ re running WampServer
❑ /Applications/MAMP/bin/php5/lib/php or similar if you ’ re running MAMP
You should also find a doc folder inside this path. Most PEAR packages come with documentation and
examples, which you ’ ll find inside this folder when the package has been installed. In addition, the
PEAR Web site contains documentation for the majority of packages; to access it, find the package page
and click the Documentation link in the page.
Depending on your setup and operating system, you may need to have access to the administrator or
root user to install PEAR packages. This is because the PEAR path is often only writable by a user with
administrative rights. On Ubuntu, Mac OS X, and other UNIX - like systems, you can usually use
sudo to install packages (for example, sudo pear install Net_UserAgent_Detect ) if
administrative rights are required.
If you ’ re working on a shared server for which you don ’ t have root access, you can still install PEAR
packages into your shared Web space. If you have SSH access to the server, you can install PEAR that
way. If you only have FTP access, you can use an excellent tool called PEAR_RemoteInstaller
that installs packages via FTP. Find out how to install via SSH or PEAR_RemoteInstaller at
.
http://pear.php.net/manual/en/installation.shared.php
Installing Dependencies
Some PEAR packages require other packages to do their work. These packages are known as
dependencies. By default, PEAR only installs the package (or packages) that you specify on the
command line. However, you can get PEAR to install any dependencies as well by adding an
- - alldeps option to the command line. For example:
pear install --alldeps Net_UserAgent_Detect
- - alldeps also installs optional packages that are related to the package you ’ re installing, but that
are not required for the package to work. If you think this is more than you need, you can use
- - onlyreqdeps to install just the required dependencies.
Uninstalling Packages
Removing a PEAR package is just as easy as installing. Simply run the package manager with the
uninstall command, followed by the name of the package to uninstall:
$ pear uninstall Net_UserAgent_Detect
uninstall ok: channel://pear.php.net/Net_UserAgent_Detect-2.5.0
$
447
9/21/09 9:14:48 AM
c15.indd 447
c15.indd 447 9/21/09 9:14:48 AM