Development and databases

Use PEAR packages in existing PHP applications

Reviewed on 2 min read php pear

PEAR distributes PHP libraries that some applications still use. If a project depends on one of those packages, you can manage it from PHP PEAR Packages in cPanel when that feature is available. For new dependencies, check whether the project uses Composer.

Find and install a package

  1. Open PHP PEAR Packages in cPanel.
  2. Search for the exact name given in the application's documentation.
  3. Check the version, whether it is maintained and its compatibility with the PHP the project uses.
  4. Install it and review the result and any dependencies that were added.

A package being in the catalogue does not guarantee that it is still maintained or that it works with every PHP version. Do not update a component shared by several applications without testing them first.

Add the search path

cPanel shows where it installs your account's components, usually /home/usuario_cpanel/php. Use the path your installation shows.

If you only need to add it for one script, keep the existing paths too:

<?php
ini_set('include_path', '/home/usuario_cpanel/php'
    . PATH_SEPARATOR . get_include_path());

Replace the username and then load the specific file the package requires, according to its documentation. If you set it from the PHP selector, check that the option is available and consider its effect on other applications that use that version.

Check or remove a package

Test the application feature that uses it and check the log if PHP cannot find a file or a dependency. Check the website's effective path and PHP, which may differ from the terminal's.

Before uninstalling, find out which projects load it. Moving to Composer requires adapting the project's installation and autoload; installing Composer does not automatically replace the require or include statements of a legacy application.

You may also find useful

Something wrong or out of date? Tell us and we will review it.