https://help.superhosting.bg/en/use-pear-package.html
  • bg
  • en

Hosting, Domains, Cloud, Virtual Private Servers (VPS), Managed VPS, SSL Certificates

How to Install and Use a PEAR Package?

Control Panel cPanel
pear package, pear packages,use pear, php pear, pear php

To start using a PEAR Package, first install it into your hosting account and then enable it for the PHP application/script.

Installing a PEAR Package

Automatic Installation in cPanel

PHP PEAR Packages in cPanelPEAR Packages are automatically installed in cPanel -> (Software) PHP PEAR Packages. In this menu you can view a list of all installed packages or add new ones.

The packages are stored into the following directory:

/home/cpuser/php
(cpuser - cPanel username)

Manual Installation via FTP or File Manager

Another option is uploading the PEAR package in your hosting account manually. A full list of all downloadable packages is available at: http://pear.php.net/packages.php

Afterwards, you can upload the package into your hosting account via FTP or File Manager.

info-icon Note: We do not recommend this option for installation. Simply uploading the package files into your hosting account will not install any dependencies (such as other PEAR packages).

Using a PEAR Package

After the package has been installed into your hosting account, you first need to specify this in the PHP application/script.

Normally that can be done with the appropriate PHP functions such as:  include()include_once() or require_once(). For example:

require_once '/home/cpuser/php/PHPUnit.php';
/home/cpuser/php - full path to the PEAR package directory;

When the PEAR package directory is not included in the PHP system path, you need to type in the full path to the executable file.

Adding the PEAR Package Directory to the PHP System Path

The include_path directive in php.ini is used to specify directories where the require, include, fopen(), file(), readfile() and file_get_contents() functions will search for files. The syntax for this path will be identical to the PATH environment variable.

info-icon The php.ini file which is used by the current PHP version on the hosting account can be easily modified in cPanel -> PHP Manager by SuperHosting -> Advanced Settings.

If the PEAR package is installed in the /home/cpuser/php directory, you should only add "/home/cpuser/php" to the include_path in php.ini:

include_path = ".:/home/cpuser/php"

If there is a value already entered for this directive (for example ".:/usr/lib/php:/usr/local/lib/php") then you should add the PEAR package path with a colon in front. For example:

include_path = ".:/usr/lib/php:/usr/local/lib/php:/home/cpuser/php"
/home/cpuser/php - the full path to the PEAR package directory; cpuser - replace it with the cPanel user;

After the package directory has been added to include_path in php.ini, а certain package functionality can be called only with the name of its executable file. For example:

require_once 'PHPUnit.php';

Setting up include_path Directly in a PHP Script

The include path can be set up or changed directly in the called script with a set_include_path() function or ini_set() that is properly working in all available PHP versions. For example:

ini_set("include_path", '/home/cpuser/php:' . ini_get("include_path") );
/home/cpuser/php - the full path to the PEAR package directory; cpuser - replace it with the cPanel user;

500px270px
SuperHosting.BG
    Control Panel cPanel
  • PHP Manager by SuperHosting
    In cPanel you can change the PHP settings for all hosting plans offered by SuperHosting.BG. You can change the PHP version, enable or disable PHP modules and change PHP directives. This... »
  • How to login to cPanel?
    You could find detailed description on how to login to cPanel in the email which you have received after your hosting account was created. One way is to write your... »
  • SuperTools Available in cPanel
    cPanel offers a few special Super tools developed by SuperHosting.BG that enable you to manage more easily and quickly the content of all websites, hosted on your account. SUPERHOSTING TOOLS In the... »
  • How to Change PHP Version for a Specific Directory?
    Under PHP Manager in cPanel you can change the PHP version for the entire hosting account or for a specific directory. Below you can read how to set a different PHP version for a specific directory... »
  • Redis Manager by SuperHosting
    Redis is supported for the SuperPro and SuperHosting plans. To use Redis, you need to activate it in cPanel. Login to cPanel and select the "Redis Manager by SuperHosting" menu. Choose the amount of... »
All rights reserved © 2005-2017 , www.superhosting.bg