Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Install a PEAR Module

This guide shows how to install a PEAR module on your hosting account using cPanel or the command line.

Domains and DNS2 min read11 steps

What is PEAR?

PHP is a language many websites run on. PEAR is a library of ready-made PHP code. Think of it as a toolbox. Instead of writing everything yourself, you can add a tool from the box. Each tool is called a module or package. Examples are Mail and Net_SMTP.

Method 1: cPanel

cPanel is your hosting control panel. Many accounts have a PEAR tool in it.

  1. Log in to cPanel. Your welcome email has the details. You can also reach it from the Services menu of your client area.
  2. Look in the Software section.
  3. Click PHP PEAR Packages. If you do not see it, it may not be on your plan. Ask support.
  4. Use the search box to find your module, for example Mail.
  5. Click Install next to the module.
  6. Wait for the success message.

Method 2: command line

This works if you have SSH access. SSH is a safe way to type commands on a remote computer. On a VPS or dedicated server, you also need root access.

  1. Connect to your server with SSH.
  2. Check that PEAR is installed.
    pear version
    This shows the PEAR version.
  3. Install your module.
    pear install Mail
    This downloads and installs the Mail module.
  4. If it needs other modules, add the dependency flag.
    pear install --alldeps Mail
    This also installs anything the module needs.
  5. List what is installed.
    pear list
    This shows all installed modules.

Use the module in your code

Add a line like the one below to your PHP file.

require_once 'Mail.php';

This loads the Mail module so your code can use it.

Tip: On shared hosting you may not be allowed to install system-wide. Use the cPanel tool. It sets up a private PEAR folder for your account. Ask Hostvento support if it is missing.
Warning: PEAR is an older tool. Many new projects use Composer instead. Back up your site before you add new code.

Quick recap

  • PEAR is a toolbox of PHP code.
  • In cPanel, use PHP PEAR Packages.
  • With SSH, run pear install.
  • Load the module with require_once.