You want to use the PEAR installer, pyrus. This allows you to install new packages, upgrade, and get information about your existing PEAR packages.
To execute a command, type the command name as the first argument on the command line:
1 |
% php pyrus.phar command |
Pyrus is a tool to manage PEAR packages. It’s not bundled with PHP, so you need to install it yourself. Fortunately, Pyrus is distributed as a self-contained PHP Archive (aka a phar). So, all that’s necessary is to download the file.
Then use PHP to run it:
1 2 3 4 5 |
% php pyrus.phar --version Pyrus version 2.0.0a4 SHA-1: 72271D92C3AA1FA96DF9606CD538868544609A52 Using PEAR installation found at /Users/rasmus/lib php pyrus.phar version 2.0.0a4. |
Here’s how to list all installed PEAR packages with the list-packages command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
% php pyrus.phar list-packages Pyrus version 2.0.0a4 SHA-1: 72271D92C3AA1FA96DF9606CD538868544609A52 Using PEAR installation found at /Users/rasmus/lib Listing installed packages [/Users/rasmus/lib]: [channel pecl.php.net]: (no packages installed in channel pecl.php.net) [channel doc.php.net]: (no packages installed in channel doc.php.net) [channel __uri]: (no packages installed in channel __uri) [channel pear.php.net]: Archive_Tar 1.3.7 stable Console_Getopt 1.3.0 stable PEAR 1.9.4 stable Structures_Graph 1.0.4 stable XML_Util 1.2.1 stable |
For a list of all valid PEAR commands, use help. pyrus has commands for both using and developing PEAR packages; as a result, there are many commands that you may not need.
The package command, for example, creates a new PEAR package. If you only run other people’s packages, you can safely ignore this command. See Table 27-2 for a list of frequently used commands.
Table 27-2. Common PEAR installer commands
Command name | Shortcut | Description |
install
upgrade uninstall list-packages list-upgrades channel-discover list-channels search |
i
up un l lu di lc s |
Download and install packages
Upgrade installed packages Remove installed packages List installed packages List all available upgrades for installed packages Initialize an alternate PEAR Channel from its server List all locally configured PEAR Channels Search for packages |
To find where your PEAR packages are located, run the get php_dir PEAR command.
You can check the value of the include_path by calling ini_get(‘include_path’) from within PHP or by looking at your php.ini file.
If you can’t alter php.ini because you’re in a shared hosting environment, add the directory to the include_path at the top of your script before including any PEAR files.
You can configure Pyrus settings using:
1 |
% php pyrus.phar set setting value |
Here setting is the name of the parameter to modify and value is the new value. To see all your current settings, use the get command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
% php pyrus.phar get Pyrus version 2.0.0a4 SHA-1: 72271D92C3AA1FA96DF9606CD538868544609A52 Using PEAR installation found at /Users/rasmus/lib System paths: php_dir => /Users/rasmus/lib/php ext_dir => /usr/lib/php/extensions/no-debug-non-zts-20121212 cfg_dir => /Users/rasmus/lib/cfg doc_dir => /Users/rasmus/lib/docs bin_dir => /usr/bin data_dir => /Users/rasmus/lib/data www_dir => /Users/rasmus/lib/www test_dir => /Users/rasmus/lib/tests src_dir => /Users/rasmus/lib/src php_bin => /usr/bin/php php_ini => /private/etc/php.ini php_prefix => php_suffix => Custom System paths: User config (from /Users/rasmus/.pear/pearconfig.xml): default_channel => pear2.php.net auto_discover => 0 http_proxy => cache_dir => /Users/rasmus/lib/cache temp_dir => /Users/rasmus/lib/temp verbose => 1 preferred_state => stable umask => 0022 cache_ttl => 3600 my_pear_path => /Users/rasmus/lib plugins_dir => /Users/rasmus/.pear (variables specific to pear2.php.net): username => password => preferred_mirror => pear2.php.net download_dir => /Users/rasmus/lib/downloads openssl_cert => handle => paranoia => 2 Custom User config (from /Users/rasmus/.pear/pearconfig.xml): (variables specific to pear2.php.net): |