PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

CHAPTER 15 ■ AN INTRODUCTION TO PEAR AND PYRUS


packages from multiple repositories. PEAR can then handle acquiring dependencies on the user’s behalf.
Before the advent of channels, the application developer had to instruct his user to install dependencies
or had to bundle them inside his own distribution.
Sebastian Bergmann’s PHPUnit package is a real-world example. In order to install it, we first need
PEAR to know about the channel in which it can be found:


$ pear channel-discover pear.phpunit.de
Adding Channel "pear.phpunit.de" succeeded
Discovery of channel "pear.phpunit.de" succeeded


Once you have established communication with this channel using discover, you can refer to a
package within it by prefacing its name with phpunit/. In fact, phpunit is just an alias for
pear.phpunit.de. You can find out about the alias for a channel by running channel-info:


$ pear channel-info pear.phpunit.de
Channel pear.phpunit.de Information:


Name and Server pear.phpunit.de
Alias phpunit
Summary PHPUnit channel server
...


■Note Pyrus does not support the channel-info subcommand


So now I can install PHPUnit:

$ pear install -a phpunit/PHPUnit


Unknown remote channel: pear.symfony-project.com
phpunit/PHPUnit can optionally use package "channel://pear.symfony-project.com/YAML"
(version >= 1.0.2)
phpunit/PHPUnit can optionally use PHP extension "pdo_mysql"
phpunit/PHPUnit can optionally use PHP extension "soap"
phpunit/PHPUnit can optionally use PHP extension "xdebug" (version >= 2.0.5)
downloading PHPUnit-3.4.11.tgz ...
Starting to download PHPUnit-3.4.11.tgz (254,439 bytes)
.....................................................done: 254,439 bytes
downloading Image_GraphViz-1.2.1.tgz ...
Starting to download Image_GraphViz-1.2.1.tgz (4,872 bytes)
...done: 4,872 bytes


install ok: channel://pear.phpunit.de/PHPUnit-3.4.11
install ok: channel://pear.php.net/Image_GraphViz-1.2.1


Notice that I used the -a flag, which asks PEAR to download all dependent packages. In this case,
that means the Image_GraphViz package from channel pear.php.net. You may also notice that the
command failed to install a package: YAML. That’s because I have not yet run channel-discover on the
channel pear.symfony-project.com. Pyrus sees this as a fatal error, so you would need to ensure that all

Free download pdf