PHP Objects, Patterns and Practice (3rd edition)

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

Dependencies


Although packages are generally stand-alone entities, they often make use of one another. Any use of
another package introduces a dependency. If the used package is not present on the user’s system, then
the package that uses it will not run as expected.
The dependencies tag is a required element, and within it, you must specify at least the PHP, and
PEAR installer versions.





5.3.0


1.4.1




Both php and pearinstall can contain min, max, and exclude elements. exlude defines a version
which will be treated as incompatible with the package, and you can include as many of these as you
need. The pearinstaller element can also contain a recommended element, in which you can set a
preferred installer for the package.
If these or other dependencies within the required element are not satisfied, PEAR will refuse to
install the package by default. A package can depend on another package, a PHP extension (such as zlib
or GD) or a particular version of PHP. Here, I insist that Dialekt has access to the Fandango package at
version 10.5.0 or greater (note, that I add this within the required element):



Fandango
pear.example.com
10.5.0

Notice the channel element; this specifies where pear should search for the package should it be
invoked with the -a flag (which tells it to acquire all dependencies). You must specify either a channel or
a uri element. The uri element should point to a package file:



Fandango
http://www.example.com/packages/fandango-10.5.0.tgz

The package element accepts the same dependency specifiers as pearinstaller, with the addition of
conflicts in which you can define a version with which this package will not work.
In addition to package you could also specify extension, os, or arch. Table 15–3 summarizes these
dependency elements.

Free download pdf