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.
- Log in to cPanel. Your welcome email has the details. You can also reach it from the Services menu of your client area.
- Look in the Software section.
- Click PHP PEAR Packages. If you do not see it, it may not be on your plan. Ask support.
- Use the search box to find your module, for example
Mail. - Click Install next to the module.
- 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.
- Connect to your server with SSH.
- Check that PEAR is installed.
This shows the PEAR version.pear version - Install your module.
This downloads and installs the Mail module.pear install Mail - If it needs other modules, add the dependency flag.
This also installs anything the module needs.pear install --alldeps Mail - List what is installed.
This shows all installed modules.pear list
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.