Women in Technology

Hear us Roar



Article:
  An Introduction to PEAR
Subject:   how can I tell if PEAR is installed?
Date:   2003-10-20 13:55:24
From:   anonymous2
Response to: how can I tell if PEAR is installed?

Assuming your machine has PEAR configured correctly and all is well the following should enlighten you as to if it is installed. Note though they may not have this package (PEAR_Info) installed... so you would prob get a fatal error... if your lucky provided by PEAR...if its installed :) - by the way when i checked this there was not docs for this package when i checked it (20th Oct 2003)... these are some of the main functions inside that class... along with


function setProxy($proxy)
function getPackages()
function getConfig()
function getCredits()
function pearImage() {
function show() {


<?php
// Include the appropriate PEAR classes
require_once("PEAR/Info.php");
$pearinfo = &new PEAR_Info();
$pearinfo->getPackages();
$pearinfo->getConfig();
$pearinfo->getCredits();
?>

Full Threads Newest First

Showing messages 1 through 2 of 2.

  • how can I tell if PEAR is installed?
    2007-07-24 07:52:05  tomski [View]

    I get an error when running getPackages()

    Warning: Invalid argument supplied for foreach() in D:\xampplite\php\pear\PEAR\Info.php on line 235

    Here's the whole script for packages, Line 235 is bold.

    function getPackages()
    {
    $latest = @$this->r->call('package.listLatestReleases');
    $available = $this->reg->listPackages();
    if (PEAR::isError($available)) {
    echo '<h1 style="font-size: 12px;">An Error occured fetching the package list. Please try again.</h1>';
    return FALSE;
    }
    if (!is_array($available)) {
    echo '<h1 style="font-size: 12px;">The package list could not be fetched from the remote server. Please try again.</h1>';
    return FALSE;
    }
    natcasesort($available);
    if ((PEAR::isError($latest)) || (!is_array($latest))) {
    $latest = FALSE;
    }
    $packages = '';
    foreach ($available as $name) {
    $installed = $this->reg->packageInfo($name);
    if (strlen($installed['package']) > 1) {
    if (!isset($old_index)) {
    $old_index = '';
    }
    $current_index = $name{0};
    if (strtolower($current_index) != strtolower($old_index)) {
    $packages .= ' () ';
    $old_index = $current_index;
    $this->index[] = $current_index;
    }
    $packages .= '
    <h2>' .trim($installed['package']). ' () </h2>
    <table>
    <tr class="v">
    <td class="e">
    Summary
    </td>
    <td>
    ' .nl2br(htmlentities(trim($installed['summary']))). '
    </td>
    </tr>
    <tr class="v">
    <td class="e">
    Version
    </td>
    <td>
    ' .trim($installed['version']). '
    </td>
    </tr>
    <tr class="v">
    <td class="e">
    Description
    </td>
    <td>
    ' .nl2br(htmlentities(trim($installed['description']))). '
    </td>
    </tr>
    <tr class="v">
    <td class="e">
    State
    </td>
    <td>
    ' .trim($installed['release_state']). '
    </td>
    </tr>
    <tr class="v">
    <td class="e">
    Information
    </td>
    </tr>';
    if ($latest != FALSE) {
    if (isset($latest[$installed['package']])) {
    if (version_compare($latest[$installed['package']]['version'],$installed['version'],'>')) {
    $packages .= '<tr class="v">
    <td class="e">
    Latest Version
    </td>
    <td>
    ' .$latest[$installed['package']]['version'] . ' (http://pear.php.net/get/' .trim($installed['package']). ')
    ('. $latest[$installed['package']]['state']. ')
    </td>
    </tr>';
    }
    }
    }
    $packages .= ' <tr>
    <td colspan="2" class="v">Top (#top) </td>
    </tr>
    </table>';
    }
    }
    ?>
    <h2>PEAR Packages () </h2>
    <table style="padding: 3px;">
    <tr>
    <td class="e">
    Index
    </td>
    </tr>
    <tr>
    <td class ="v" style="text-align: center">
    <?php
    foreach ($this->index as $i) {
    ?>

    | <?php echo strtoupper($i); ?> (#<?php echo $i; ?>)
    <?php
    }
    ?>|
    </td>
    </tr>
    </table>


    <?php
    echo $packages;
    }

    <b>Thanks for for any help. I would like to view my installed packages.

    Tom
  • how can I tell if PEAR is installed?
    2007-07-24 07:52:42  tomski [View]

    I get an error when running getPackages()

    Warning: Invalid argument supplied for foreach() in D:\xampplite\php\pear\PEAR\Info.php on line 235

    Here's the whole script for packages, Line 235 is bold.

    function getPackages()
    {
    $latest = @$this->r->call('package.listLatestReleases');
    $available = $this->reg->listPackages();
    if (PEAR::isError($available)) {
    echo '<h1 style="font-size: 12px;">An Error occured fetching the package list. Please try again.</h1>';
    return FALSE;
    }
    if (!is_array($available)) {
    echo '<h1 style="font-size: 12px;">The package list could not be fetched from the remote server. Please try again.</h1>';
    return FALSE;
    }
    natcasesort($available);
    if ((PEAR::isError($latest)) || (!is_array($latest))) {
    $latest = FALSE;
    }
    $packages = '';
    foreach ($available as $name) {
    $installed = $this->reg->packageInfo($name);
    if (strlen($installed['package']) > 1) {
    if (!isset($old_index)) {
    $old_index = '';
    }
    $current_index = $name{0};
    if (strtolower($current_index) != strtolower($old_index)) {
    $packages .= ' () ';
    $old_index = $current_index;
    $this->index[] = $current_index;
    }
    $packages .= '
    <h2>' .trim($installed['package']). ' () </h2>
    <table>
    <tr class="v">
    <td class="e">
    Summary
    </td>
    <td>
    ' .nl2br(htmlentities(trim($installed['summary']))). '
    </td>
    </tr>
    <tr class="v">
    <td class="e">
    Version
    </td>
    <td>
    ' .trim($installed['version']). '
    </td>
    </tr>
    <tr class="v">
    <td class="e">
    Description
    </td>
    <td>
    ' .nl2br(htmlentities(trim($installed['description']))). '
    </td>
    </tr>
    <tr class="v">
    <td class="e">
    State
    </td>
    <td>
    ' .trim($installed['release_state']). '
    </td>
    </tr>
    <tr class="v">
    <td class="e">
    Information
    </td>
    </tr>';
    if ($latest != FALSE) {
    if (isset($latest[$installed['package']])) {
    if (version_compare($latest[$installed['package']]['version'],$installed['version'],'>')) {
    $packages .= '<tr class="v">
    <td class="e">
    Latest Version
    </td>
    <td>
    ' .$latest[$installed['package']]['version'] . ' (http://pear.php.net/get/' .trim($installed['package']). ')
    ('. $latest[$installed['package']]['state']. ')
    </td>
    </tr>';
    }
    }
    }
    $packages .= ' <tr>
    <td colspan="2" class="v">Top (#top) </td>
    </tr>
    </table>';
    }
    }
    ?>
    <h2>PEAR Packages () </h2>
    <table style="padding: 3px;">
    <tr>
    <td class="e">
    Index
    </td>
    </tr>
    <tr>
    <td class ="v" style="text-align: center">
    <?php
    foreach ($this->index as $i) {
    ?>

    | <?php echo strtoupper($i); ?> (#<?php echo $i; ?>)
    <?php
    }
    ?>|
    </td>
    </tr>
    </table>


    <?php
    echo $packages;
    }

    <b>Thanks for for any help. I would like to view my installed packages.

    Tom

    Please send response to tturowski@gmail.com also.