PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

■Chapter 15: An Introduction to PEAR and Pyrus ...............................................


(on Linux or Unix systems this will often be /usr/local/lib/php). You can check this using the pear
command line application:


$ pear config-get php_dir
/usr/local/lib/php


The core packages (known as the PEAR Foundation Classes) provide a backbone for the wider
repository—including core functions such as error handling and the processing of command line
arguments.


■Note If you use a Unix distribution to install PHP, you may begin with a minimal installation. For example, to get


PHP and PEAR on Fedora 12 you would need issue these commands:


sudo yum install php


sudo yum install php-pear


See your distribution’s documentation if you wish to use its package management tools to manage
PHP. You have already seen the pear application in action. This is a tool for interacting with all aspects of
PEAR, and as such, it is an important part of PEAR in itself. The pear application supports a number of
subcommands. We used config-get, which shows the value of a particular configuration setting. You
can see all settings and their values with the config-show subcommand:


$ pear config-show


$ pear config-show
Configuration (channel pear.php.net):


Auto-discover new Channels auto_discover
Default Channel default_channel pear.php.net
HTTP Proxy Server Address http_proxy
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config
PEAR executables directory bin_dir /usr/bin
...


Phar Out with Pyrus


Before I go any further, I should introduce a newcomer to the PEAR world. Pyrus is the next generation
of the PEAR application. The name comes from the genus of trees and shrubs that includes the pear tree.
Incidentally, Pirus is the Latin for “pear tree.” You can get Pyrus at http://pear2.php.net. The
application you will download is a phar package (PHP Archive). If you are familiar with Java, you will
recognize a PHP analog to the jar file. A phar is essentially a bundle of code compressed into a zip file.
It’s a neat way of passing round library code. After download you can simply run Pyrus like this:


php pyrus.phar

Free download pdf