| Article: |
An Introduction to PEAR | |
| Subject: | how can I tell if PEAR is installed? | |
| Date: | 2001-08-29 08:42:13 | |
| From: | ziatroyano | |
| My site is hosted by another provider. Is there a way I can tell if PEAR is installed on the server without having direct access to it? | ||
Showing messages 1 through 4 of 4.
-
how can I tell if PEAR is installed?
2003-10-20 13:55:24 anonymous2 [View]
-
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.
-
how can I tell if PEAR is installed?
2007-03-18 09:15:56 ajay.kumar.singh [View]
You should have install driver for mysql
$dsn = 'mysql://test_user:test_pw@localhost/test_db';
simpleQuery is not in use right now, to launch the query simply use $dbobj->query() passing a query string in query function using above dsn.
Regards,
ajay



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();
?>