This guide assumes you've already installed PEAR using the following guide:
It’s possible your PHP site will throw an error if certain PEAR packages are not installed. For example, if you get an error referencing any of the following, run the command below (in your user's directory) to install that package.
|Error reference||Command to fix|
[server]$ pear install --alldeps Mail
[server]$ pear install --alldeps Mail_Mime
[server]$ pear install --alldeps Console_Getopt
[server]$ pear install --alldeps MDB2
[server]$ pear install --alldeps Net_SMTP
When you create a script that references PEAR, make sure to add these two lines at the very top of that script:
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); set_include_path("." . PATH_SEPARATOR . ($UserDir = dirname($_SERVER['DOCUMENT_ROOT'])) . "/pear/php" . PATH_SEPARATOR . get_include_path());
- The first line turns off any errors that may show.
- The second line allows the script to reference your PEAR installation.
Additionally, you may need to include the configuration file that you created. The configuration file includes variables for template and data path, which are required for some PEAR modules:
$pear_user_config = $UserDir . "/.pearrc";
Where $UserDir = dirname($_SERVER['DOCUMENT_ROOT']) dynamically determines your user's home directory, e.g., /home/username.
You may see the following error after attempting to install a package:
[server]$ pear install --onlyreqdeps Mail No releases available for package "pear.php.net/Mail" install failed
To fix this error, view the following article:
If that doesn't work, try updating channels and upgrading. This will display if there are any errors connecting to pear.php.net. For example:
[server]$ pear update-channels Updating channel "doc.php.net" Update of Channel "doc.php.net" succeeded Updating channel "pear.php.net" Channel "pear.php.net" is not responding over http://, failed with message: Connection to `ssl://pear.php.net:443' failed: Trying channel "pear.php.net" over https:// instead Cannot retrieve channel.xml for channel "pear.php.net" (Connection to `ssl://pear.php.net:443' failed: ) Updating channel "pecl.php.net" Update of Channel "pecl.php.net" succeeded [server]$ pear upgrade Error getting channel info from pear.php.net: Connection to `ssl://pear.php.net:443' failed:
In this case it's an issue with the pear.php.net website that needs to be resolved on their end.