Pear Modules Tutorial
Table of Contents
How to see currently installed PEAR modules
To see the currently installed PEAR modules, first, access your account via SSH. Then, depending on the PHP version you want to see the available modules on, execute the following command:
pearXX list
Replace XX with the PHP version. For example to see the available PEAR modules for PHP7.4, use:
user@servername [~/public_html]# pear74 list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.4.3 stable
Console_Getopt 1.4.1 stable
PEAR 1.10.5 stable
Structures_Graph 1.1.1 stable
XML_Util 1.4.2 stable
How to install an additional PEAR package?
In addition to the already installed PEAR packages, you can install new ones. For example, you can add a Calendar module. To do that, first, go to pear.php.net. Then in the search box at the top right corner type Calendar and click on Search.
This will show you all the Packages that have the word “calendar” inside. Click the first result – “Calendar: A package for building Calendar data structures (irrespective of output)”.
You will be redirected to the package page. From there click the Download tab.
Next, click the latest version available in the Download section to start downloading the package.
Once you have the package downloaded locally, you have to extract it on your computer. This will produce a folder named Calendar-X.X.X where X.X.X is the version of the package.
Next, connect to your account via SSH and create a directory named PEAR right in the home directory of your account – /home/customer/. Upload the Calendar directory inside the PEAR one. You should upload any other Pear packages there.
Configure PHP to include the local PEAR directory. This can be done by creating a file named php.ini and pasting the following line inside it:
include_path = ".:/usr/local/phpXX/lib/php:/home/customer/PEAR";
In the above line, phpXX should be replaced with the proper PHP version number, i.e. for php7.4 it should be php74. This php.ini file must be copied in each directory where pear packages are needed.
From this point on the Calendar Pear package will be available with the fixed path:
include 'Calendar-X.X.X/Calendar.php';