PHP Packages
Using the PEAR Installer
Problem
You want to use the PEAR installer, pyrus. This allows you to install new packages, upgrade, and get information about your existing PEAR packages.
Solution
Install Pyrus.
To execute a command, type the command name as the first argument on the command line:
% php pyrus.phar command
Discussion
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 (akaa phar). So, all that’s necessary is to download the file.
Then use PHP to run it:
% 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:
% 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.
Table Common PEAR installer commands
Command name Shortcut Description
install i Download and install packages
upgrade up Upgrade installed packages
uninstall un Remove installed packages
list-packages l List installed packages
list-upgrades lu List all available upgrades for installed packages
channel-discover di Initialize an alternate PEAR Channel from its server
list-channels lc List all locally configured PEAR Channels
search s 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:
% 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:
% 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):
No comments:
Post a Comment