How to use PEAR in your web hosting account
Added: 10.03.2014 23:26:29 Last updated: 24.09.2015 10:07:23
You can install any PEAR packages you might need as shown in the guide Installing PEAR packages in cPanel. The PEAR packages path must be added in include_path for you to be able to make use of them in PHP script. In the guide Installing PEAR packages in cPanel you can see a path to the PEAR packages in step 2 point 1. You can add this in two ways:
- Via php.ini file
The guide Configuration of php.ini shows how to set up a file like this. To add a path to the packages, the following line must be added to the php.ini file:
include_path = '.:/home/ttesting/php:/usr/lib/php:/usr/local/lib/php';Here, ":/home/ttesting/php" is added to include_path (the rest of include_path is standard for all web hosting accounts). The path to the packages should be added first in include_path after "." and it is important to note that every path in include_path is separated with the character ":".
- Via ini_set()
include_path can also be set via the PHP code via the ini_set() function in PHP. The following line must in this case be added to the PHP code:
The difference between the two methods is that all scripts will include the PEAR packages if you use the php.ini file, while it will only be the code that is run after ini_set() which will include the PEAR packages in the last method.