2.3. Installing a PEAR Package

After you have the PEAR manager installed and running on your server or local machine (which we talk about in the preceding sections), you can start installing PEAR packages. You first must decide what packages you need.

Point your Web browser to the PEAR package browser at http://pear.php.net/packages.php and browse until you find the package that fits your needs. Take note of the package name, as shown in Figure 2-3.

Figure 2-3. Make a note of the package name for the installation process.

2.3.1. Installing a PEAR package from the command line

Open a command line window (in Windows) or a shell (in Linux/Unix/Mac) and type the following command:

pear install package_name

If the package you want to use has a state other than stable, you have to force the installation in one of the following ways:

  • Use the –beta flag:

    pear install package_name-beta
  • Set the preferred state by using the config-set command:

    pear config-set preferred_state beta
    pear install package_name
    pear config-set preferred_state stable
  • Set the preferred state by using the -d switch:

    pear -d preferred_state=beta install package_name
  • Brute force the installation:

    pear install -f package_name

You just have to get the installation started and relax — the PEAR command line installer takes care of the rest of the details.

If you don't want to install a package immediately, or if you need ...

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.