CHAPTER 15 ■ AN INTRODUCTION TO PEAR AND PYRUS
Installing a Package
Once you have selected your package, you can download and install it with a single command. Here is
the process for installing Log, a package that provides enhanced support for error logging:
$ pear install pear/Log
■Note In most instances, you will need root privileges to install, update, and remove packages with PEAR, because
this involves writing to areas of the computer outside of your home space. If you do not have write permissions for
these areas, however, all is not lost. In the section “Creating Your Own PEAR Packages,” I describe how to change the
default installation locations. This will allow you to install packages within your own writeable space.
It really is as simple as that. The PEAR installer is bundled with PHP and locates, downloads, and
installs the Log package on your behalf. Here’s the command’s output:
Did not download optional dependencies: pear/DB, pear/MDB2,
use --alldeps to download automatically
pear/Log can optionally use package "pear/DB" (version >= 1.3)
pear/Log can optionally use package "pear/MDB2" (version >= 2.0.0RC1)
downloading Log-1.12.0.tgz ...
Starting to download Log-1.12.0.tgz (38,479 bytes)
..........done: 44,555 bytes
install ok: channel://pear.php.net/Log-1.9.11
The Log package has some optional dependencies, which you can safely ignore unless you require
functionality associated with the missing packages. Notice the last line. PEAR tells you that it acquired
the Log package from the channel pear.php.net. In fact, I specified as much by installing pear/Log rather
than just Log. I’ll return to channels shortly.
Pyrus can also install the Log package:
php ./pyrus.phar install pear/Log
Pyrus version 2.0.0a1 SHA-1: 27EB8EB427EA50C05691185B41BBA0F0666058D0
Using PEAR installation found at /usr/share/pear2
Connected...
Installed pear.php.net/Log-1.12.0
Optional dependencies that will not be installed, use --optionaldeps:
pear.php.net/DB depended on by pear.php.net/Log
pear.php.net/MDB2 depended on by pear.php.net/Log
pear.php.net/Mail depended on by pear.php.net/Log