PEAR Articles

  Home arrow PEAR Articles arrow Page 3 - Installing PEAR
PEAR ARTICLES

Installing PEAR
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2010-07-28

    Table of Contents:
  • Installing PEAR
  • Installing a PEAR Package
  • Including a Package Within Your Scripts
  • Uninstalling a Package

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Installing PEAR - Including a Package Within Your Scripts


    (Page 3 of 4 )

    Using an installed PEAR package is simple. All you need to do is make the package contents available to your script with include or preferably require. Keep in mind that you need to add the PEAR base directory to yourinclude_pathdirective; otherwise, an error similar to the following will occur:

    --------------------------------------------
    Fatal error: Class 'MDB2' not found in /home/www/htdocs/book/11/database.php
    on line 3
    --------------------------------------------

    Those of you with particularly keen eyes might have noticed that in the earlier example involving theNumbers_Romanpackage, a directory was also referenced:

    require_once("Numbers/Roman.php");

    A directory is referenced because theNumbers_Romanpackage falls under theNumberscategory, meaning that, for purposes of organization, a corresponding hierarchy will be created, withRoman.phpplaced in a directory namedNumbers. You can determine the package’s location in the hierarchy simply by looking at the package name. Each underscore is indicative of another level in the hierarchy, so in the case ofNumbers_Roman, it’sNumbers/Roman.php. In the case ofMDB2, it’s justMDB2.php.


    Note  See Chapter 2 for more information about theinclude_pathdirective.

    See Chapter 2 for more information about the directive.


    Upgrading Packages

    All PEAR packages must be actively maintained, and most are in a regular state of development. That said, to take advantage of the latest enhancements and bug fixes, you should regularly check whether a new package version is available. You can upgrade a specific package, or all packages at once.

    Upgrading a Single Package

    The general syntax for upgrading a single package looks like this:

    %>pear upgrade [package name]

    For instance, on occasion you’ll want to upgrade the PEAR package, responsible for managing your package environment. This is accomplished with the following command:

    %>pear upgrade pear

    If your version of a package corresponds with the latest release, you’ll see a message that looks like the following:

    --------------------------------------------
    Package 'PEAR-1.4.9' already installed, skipping
    --------------------------------------------

    If for some reason you have a version that’s greater than the version found in the PEAR repository (e.g., you manually downloaded a package from the package author’s Web site before it was officially updated in PEAR), you’ll see a message that looks like this:

    --------------------------------------------
    Package 'PEAR' version '1.4.9' is installed and 1.4.9 is > requested '1.4.8',
    skipping
    --------------------------------------------

    Otherwise, the upgrade should automatically proceed. When completed, you’ll see a message that looks like the following:

    --------------------------------------------
    downloading PEAR-1.4.10.tgz ...
    Starting to download PEAR-1.4.10.tgz (106,079 bytes)
    ........................done: 106,079 bytes upgrade ok: PEAR 1.4.10
    --------------------------------------------

    Upgrading All Packages

    It stands to reason that you’ll want to upgrade all packages residing on your server, so why not perform this task in a single step? This is easily accomplished with theupgrade-allcommand, executed like this:

    %>pear upgrade-all

    Although unlikely, it’s possible some future package version could be incompatible with previous releases. That said, using this command isn’t recommended unless you’re well aware of the consequences surrounding the upgrade of each package.

    More PEAR Articles Articles
    More By Apress Publishing

    blog comments powered by Disqus

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap