Thursday, February 4, 2010

Recipe 26.4. Installing PEAR Packages










Recipe 26.4. Installing PEAR Packages



26.4.1. Problem


You want to install a PEAR package.




26.4.2. Solution


Download and install the package from the appropriate PEAR Channel server using the PEAR installer:


% pear install Package_Name



You can also install from another PEAR Channel:


% pear install channel/Package_Name



You can also install from any location on the Internet:


% pear install http://pear.example.com/Package_Name-1.0.0.tgz



Here's how to install if you have a local copy of a package:


% pear install Package_Name-1.0.0.tgz





26.4.3. Discussion


To install PEAR packages, you need write permission where the packages are stored; this defaults to /usr/local/lib/php/.


You can also request multiple packages at the same time:


% pear install XML_Parser XML_Tree
downloading XML_Parser-1.2.7.tgz ...
Starting to download XML_Parser-1.2.7.tgz (12,939 bytes)
.....done: 12,939 bytes
downloading XML_Tree-1.1.tgz ...
Starting to download XML_Tree-1.1.tgz (4,826 bytes)
...done: 4,826 bytes
install ok: channel://pear.php.net/XML_Tree-1.1
install ok: channel://pear.php.net/XML_Parser-1.2.7



When installing a package, PEAR checks that you have all the necessary PHP functions and PEAR packages that the new package depends on. If this check fails, PEAR reports on the dependencies:


% pear install MDB2_Driver_Mysql
install MDB2_Driver_Mysql
Did not download dependencies: pear/MDB2, use --alldeps or --onlyreqdeps to
download automatically
pear/MDB2_Driver_mysql requires package "pear/MDB2" (version >= 2.0.1)
No valid packages found
install failed



As you can see from the error message, the PEAR installer made no attempt to download dependencies. This default behavior puts you in control by not assuming that you want to install or upgrade the related dependencies. The most convenient install command switch is -o, which is the shortcut for --onlyreqdeps, which installs all required dependencies.


Using the -o switch, the installation is now successful:


% pear install -o MDB2_Driver_Mysql
downloading MDB2_Driver_mysql-1.0.1.tgz ...
Starting to download MDB2_Driver_mysql-1.0.1.tgz (22,240 bytes)
........done: 22,240 bytes
downloading MDB2-2.0.1.tgz ...
Starting to download MDB2-2.0.1.tgz (91,219 bytes)
...done: 91,219 bytes
install ok: channel://pear.php.net/MDB2-2.0.1
install ok: channel://pear.php.net/MDB2_Driver_mysql-1.0.1



If you want to ignore the required dependencies, you can use the -n or --nodeps switches to tell the installer to ignore dependencies and install anyway.




26.4.4. See Also


26.7 for information on installing PECL packages; Recipe 26.5 for more on upgrading an existing package; Recipe 26.6 to uninstall a package.













No comments: