PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 15 ■ AN INTRODUCTION TO PEAR AND PYRUS

From here onward, I’ll mention differences between the two systems rather than demonstrate them
both in parallel.
If the package you wish to install has compulsory dependencies, the installation will fail with a
warning message by default:


pear/dialekt requires package "pear/Fandango" (version >= 10.5.0)
No valid packages found


You can either install the required package before trying again, or you could run pear install with
the -o flag.


pear install -o dialekt


The -o flag ensures that the PEAR installer will automatically install any required dependencies for
you. Some PEAR packages specify optional dependencies, and these are ignored if -o is specified. To
have all dependencies installed automatically, use the -a flag instead.


■Note Pyrus will attempt to install dependencies by default. It supports an -o flag, which will cause optional


dependencies to be installed as well.


Although PEAR is designed to talk to a repository over a network online, you will find that some
developers produce PEAR-compatible packages for ease of installation. You may be given the location of
a tarball (a tarred and gzipped package). Installing this using PEAR is almost as easy as installing an
official package:


$ pear install -o http://www.example.com/dialekt-1.2.1.tgz
downloading dialekt-1.2.1.tgz ...
Starting to download dialekt-1.2.1.tgz (1,783 bytes)
....done: 1,783 bytes
install ok: channel://pear.php.net/dialekt-1.2.1


You can also download a package and install it from the command line. Here, we use a Unix
command called wget to fetch the dialekt package before installing it from the command line:


$ wget -nv http://127.0.1.2:8080/dialekt-1.2.1.tgz
20:21:40 URL:http://127.0.1.2:8080/dialekt-1.2.1.tgz [1783/1783]


-> "dialekt-1.2.1.tgz.1" [1]
$ pear install dialekt-1.2.1.tgz


install ok: channel://pear.example.com/Dialekt-1.2.1


You can install a PEAR package by referencing an XML file (usually named package.xml), which
provides information about what files are to be installed where.


$ pear install package.xml
install ok: channel://pear.example.com/Dialekt-1.2.1


PEAR Channels


PEAR introduced channels in version 1.4. This powerful feature allows you to poll repositories other than
pear.php.net for updates and dependencies. This means that you can build an application that requires

Free download pdf