Home » PEAR » PEAR_Info » Manual
Displays Information about your current PEAR install. Akin to PHP's phpinfo().
Summary
Features
- generates a comprehensive information page for your current PEAR install.
- the format for the page is similar to that for phpinfo() except using PEAR colors.
- have complete PEAR Credits (based on the packages you have installed).
- will show if there is a newer version than the one presently installed (and what its state is).
- a default style sheet is provided by default, but render is fully customizable
- outputs plain text instead of HTML when using the CLI mode (since version 1.8.0).
- show list of all files PEAR searches for configs, not only the files that were actually read (since version 1.9.0).
System Requirements
Mandatory resources :
Optional resources :
- PHPUnit 3.1.4 or newer.
About
FAQ
FAQ – Answers to most Frequently Asked Questions
PEAR_Info FAQ
- What does it cost ?
- Do you offer support ?
- I found a bug, what shall I do ?
- What is PEAR ?
- I want to display my system configuration, but this one is not detected ?
- I want to change the look an feel (colors) of PEAR_Info output ?
- I want to display packages from all my channels ?
- I want to check if a package is installed or not ?
- What does it cost ?
-
You can download and use it for free. But don't delete the copyright notice. You can read terms of the PHP license.
- Do you offer support ?
-
YES if there is no answer in this Guide and if you are ready to share some informations such as : your configuration (platform Win *nix mac, PHP version, PEAR packages installed) and perharps your script.
- I found a bug, what shall I do ?
-
You can report it with the bug tracker at PEAR.
- What is PEAR ?
-
PEAR (an acronym for PHP Extension and Application Repository) is a framework and distribution system for reusable PHP components.
Don't forget to read also the PEAR Manual and PEAR FAQ.
- I want to display my system configuration, but this one is not detected ?
-
If your system file (see command pear config-show) does not exists, or is locate in another directory, then you should give this information on PEAR_Info class constructor.
<?php // @link http://pear.php.net/bugs/bug.php?id=12878 // Search for pear.conf inside /etc/pear/ require_once 'PEAR/Info.php'; $pear_dir = ''; $user_file = ''; $syst_file = '/etc/pear/pear.conf'; $info = new PEAR_Info($pear_dir, $user_file, $syst_file); $info->display(); ?>
- I want to change the look an feel (colors) of PEAR_Info output ?
-
First copy the default stylesheet named
pearinfo.css(locate in{data_dir}/PEAR_Info: see command pear config-show) as a pattern. Then second, change colors and whatever you want until you keep all CSS selectors.See for example the blue layout pattern skin locate in package installation under name
{doc_dir}/PEAR_Info/examples/blueskin.css.Last, as
{doc_dir}/PEAR_Info/examples/pear_info2.phpscript, set the new stylesheet withPEAR_Info::setStyleSheet.<?php require_once 'PEAR/Info.php'; $info = new PEAR_Info(); $info->setStyleSheet(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'blueskin.css'); $info->display(); ?>
- I want to display packages from all my channels ?
-
By default PEAR_Info display only informations from
pear.php.netchannel.To remove this limit, give as option to the class constructor an empty channels list, as below :
<?php require_once 'PEAR/Info.php'; $pear_dir = ''; $user_file = ''; $syst_file = '/opt/lampp/etc/pear.conf'; $options = array('channels' => array() ); $info = new PEAR_Info($pear_dir, $user_file, $syst_file, $options); $info->display(); ?>If you want to filter package listing from a channel list, then give the full qualified list; something like :
<?php $options = array('channels' => array('pear.php.net', 'pear.phpunit.de', '__uri') ); ?>
- I want to check if a package is installed or not ?
-
With static method
PEAR_Info::packageInstalled, you can check installation of a package from all channels declared, and also filter by version.<?php require_once 'PEAR/Info.php'; $inst = PEAR_Info::packageInstalled('Role_Web', '1.1.0', 'pearified'); if ($inst === false) { echo 'sorry it seems that "pearified/Role_Web" package is not installed' . ' or version is less than 1.1.0'; } ?>
News
News – What is New in version ?
Version 1.0.x
- Initial PEAR public release occured at end of April 2003.
-
Moved output of the PEAR_Info
to
PEAR_Info::show() - Local PEAR logo copy included
- Added PEAR Configuration section to the output
Version 1.5.x
- Allows Off-Line viewing
- Shows *all* installed packages, whether in PEAR or not
- You can now specify a custom PEAR config file
Version 1.6.x
-
Added static method,
PEAR_Info::packageInstalled(). Allows to check if a package is installed or not.
Version 1.7.x
- Easy change look and feel with a simple CSS file
- Show packages dependencies list
- HTML page output is XHTML compliant
- Introduce a full and flexible configuration system to show only information you want
- Show channel list
- Show maintainer inactive status in Credits page
- Support REST 1.0 protocol
- Drop support of package xml 1.0
- Credits page is now customizable with PEAR_INFO_CREDITS_* constant
- You may have a standalone html page (default behavior) with PEAR_INFO_FULLPAGE, or part of it
- Removed support of PEAR 1.3.x
- Upgrade requirement to PHP 4.3.0 and PEAR 1.5.4 (to avoid security vulnerability)
- Coding Standard fixes (errors/warnings) following recommandation by PHP_CodeSniffer
Version 1.8.x
- PEAR_Info is also available now on command line (CLI), and display a text report as phpinfo() did.
Version 1.9.x
- Beautify Html output with some additional links
- Show list of all files PEAR searches for configs, not only the files that were actually read. Render of alternative configuration file found/notfound is allowed by CSS selectors.
- fix encoding character in credits page for Sérgio Carvalho and Stig Sæther Bakken
- improve render and display index only when there are packages (in main page) improve render and did not display maintainers empty list (in credits page)
- add a counter of installed packages for each channel (in main page)
Introduction
Introduction – Introduction to PEAR_Info
Introduction to PEAR_Info
PEAR_Info obtains and displays information about your current PEAR Install. The PEAR_Info page features an A-Z index for easy searching, aswell as anchors for each package in the form of pkg_Package_Name (i.e. url.tld/pearinfo.php#pkg_PEAR_Info) PEAR_Info also features a full 'PEAR Credits' page, with information about the authors of the packages you currently have installed. PEAR_Info will also display any later versions that are available from PEAR to help keep you up to date.
Using PEAR_Info
<?php
require_once 'PEAR/Info.php';
/*
If you need to set a http_proxy value at run-time that is not set in
your user or system pear configuration file, you can use the
following, this must be called BEFORE instantiating the PEAR_Info object
*/
PEAR_Info::setProxy('your.proxy.here');
/*
Optional pear_dir variable, allows you to choose where your PEAR
install is, in case it's not found
*/
$pear_dir = "/path/to/your/pear/files";
/*
Instantiate PEAR_Info object
*/
$info = new PEAR_Info($pear_dir);
/*
Show PEAR_Info output
*/
$info->display();
?>
PEAR_Info options
The output may be customized by passing one or more of the following constants bitwise values summed together in the optional options hash parameter. One can also combine the respective constants or bitwise values together with the or operator.
| Name | Value | Description |
|---|---|---|
| PEAR_INFO_GENERAL | 1 | The configuration file location, PEAR logo and current install version. |
| PEAR_INFO_CREDITS | 2 | A link to PEAR Credits page. See also PEAR_INFO_CREDITS_* constants. |
| PEAR_INFO_CONFIGURATION | 4 | All PEAR settings (keys and values). |
| PEAR_INFO_CHANNELS | 8 | List available channels |
| PEAR_INFO_PACKAGES | 4080 | All package informations. See all others PEAR_INFO_PACKAGES_* constants. |
| PEAR_INFO_PACKAGES_CHANNEL | 2048 | Show the package channel |
| PEAR_INFO_PACKAGES_SUMMARY | 1024 | A short description of the package |
| PEAR_INFO_PACKAGES_VERSION | 512 | Package version with state and release date. |
| PEAR_INFO_PACKAGES_LICENSE | 256 | License of the package release |
| PEAR_INFO_PACKAGES_DESCRIPTION | 128 | A long description of the package |
| PEAR_INFO_PACKAGES_DEPENDENCIES | 64 | Show package dependency list |
| PEAR_INFO_PACKAGES_XML | 32 | Tell what PEAR packager and package xml version (1.0 or 2.0) was used to build and install the package. |
| PEAR_INFO_PACKAGES_UPDATE | 16 | Show the latest version available. Displayed only if different than current install version. |
| PEAR_INFO_ALL | 4095 | Shows all of the above. This is the default value. |
| Name | Value | Description |
|---|---|---|
| PEAR_INFO_CREDITS_ALL | 61440 | All credits informations. See all others PEAR_INFO_CREDITS_* constants. |
| PEAR_INFO_CREDITS_GROUP | 4096 | Show PEAR Group members list |
| PEAR_INFO_CREDITS_DOCS | 8192 | Show PEAR Documentation Team list |
| PEAR_INFO_CREDITS_WEBSITE | 16384 | Show PEAR Website Team list |
| PEAR_INFO_CREDITS_PACKAGES | 32768 | Show authors (and roles) of package maintainers |
| Name | Value | Description |
|---|---|---|
| PEAR_INFO_FULLPAGE | 65536 | Indicates that a complete stand-alone HTML page needs to be printed including the information indicated by the other flags. This is the default value. |
Customize PEAR_Info output
<?php
require_once 'PEAR/Info.php';
/*
Optional resume option, allows you to choose what information to display.
Here we will display a quick list of package (version only) group by channel.
*/
$options = array('resume' => PEAR_INFO_FULLPAGE |
PEAR_INFO_GENERAL | PEAR_INFO_CHANNELS | PEAR_INFO_PACKAGES_VERSION,
'channels' => array()
);
/*
Instantiate PEAR_Info object, using PEAR default install configuration
*/
$info = new PEAR_Info('', '', '', $options);
/*
Set you own presentation size and colors, with a simple style sheet.
*/
$css_file = "/path/to/your/file.css";
$info->setStyleSheet($css_file);
/*
Show PEAR_Info output
*/
$info->display();
?>
Reference guide
constructor PEAR_Info::PEAR_Info
constructor PEAR_Info::PEAR_Info() – PHP 4 style constructor (ZE1)
Synopsis
require_once 'PEAR/Info.php';
void constructor PEAR_Info::PEAR_Info (
string $pear_dir
= ''
, string $user_file
= ''
, string $system_file
= ''
, array $options
= null
)
Description
$user_file,$system_fileand$optionsparameters are available since version 1.7.0RC1, allowing to define more easily the PEAR configuration files, and choose what information to display akin to PHP's phpinfo().
Parameter
-
string
$pear_dir -
(optional) The PEAR base install directory
-
string
$user_file -
(optional) file to read PEAR user-defined options from
-
string
$system_file -
(optional) file to read PEAR system-wide defaults from
-
array
$options -
(optional) configure PEAR information output
Throws
throws no exceptions thrown
Since
since version 1.0.1 (2003-04-24)
Note
This function can not be called statically.
Example
<?php
require_once 'PEAR/Info.php';
// Display only PEAR version and logo, reference to config file, list of channels
// and quick list of packages (with only version info) installed thru channels
// pear, __uri, pecl.
$options = array('resume' => PEAR_INFO_GENERAL | PEAR_INFO_CHANNELS | PEAR_INFO_PACKAGES_VERSION,
'channels' => array('pear.php.net', '__uri', 'pecl.php_net')
);
// Give PEAR install directory where to find pear.ini or pearsys.ini files
$info = new PEAR_Info('c:\wamp\php', '', '', $options);
$info->display();
?>
PEAR_Info::display
PEAR_Info::display() – Displays PEAR_Info output
Synopsis
require_once 'PEAR/Info.php';
void PEAR_Info::display (
)
Description
Displays PEAR_Info output depending of style applied (style sheet).
Throws
throws no exceptions thrown
Since
since version 1.7.0RC1 (2007-07-01)
Note
This function can not be called statically.
See
PEAR_Info::getMembers
PEAR_Info::getMembers() – Returns a members list depending of its category (group, docs, website)
Synopsis
require_once 'PEAR/Info.php';
array
PEAR_Info::getMembers
(
string
$group
= 'all'
,
bool
$sort
= true
)
Description
Retrieve the members list of PEAR group, PEAR doc team, or PEAR website team
Parameter
-
string
$group -
(optional) Member list category. Either president, group, docs or website
-
boolean
$sort -
(optional) Return a member list sorted in alphabetic order
Throws
throws no exceptions thrown
Since
since version 1.7.0RC3 (2007-07-10)
Note
This function can not be called statically.
PEAR_Info::getStyleSheet
PEAR_Info::getStyleSheet() – Returns the custom style sheet to use for presentation
Synopsis
require_once 'PEAR/Info.php';
string PEAR_Info::getStyleSheet (
boolean $content
= true
)
Description
Default behavior is to return css string contents.
Sets $content parameter to FALSE will return css filename
reference (defined by setStyleSheet function).
Easy for a <link rel="stylesheet" type="text/css"
href="" /> html tag integration (see example below).
Parameter
-
boolean
$content -
(optional) Either return css filename or string contents
Throws
throws no exceptions thrown
Since
since version 1.7.0RC1 (2007-07-01)
Note
This function can not be called statically.
Return value
string - returns css filename or css string contents
Example
<?php
// require the PEAR_Info file
require_once 'PEAR/Info.php';
class PEAR_Info3 extends PEAR_Info
{
function PEAR_Info3($pear_dir = '', $user_file = '', $system_file = '')
{
$this->__construct($pear_dir, $user_file, $system_file);
}
function toHtml()
{
$styles = basename($this->getStyleSheet(false));
$body = $this->info;
$html = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="author" content="Laurent Laville" />
<title>My PEAR_Info()</title>
<link rel="stylesheet" type="text/css" href="$styles" />
</head>
<body>
<div id="header">
<h1>Laurent-Laville.org</h1>
</div>
<div id="footer">
</div>
<div id="contents">
$body
</div>
</body>
</html>
HTML;
return $html;
}
}
// Create PEAR_Info object
$info = new PEAR_Info3();
// set your own styles, rather than use the default stylesheet
$info->setStyleSheet(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pearinfo3.css');
// Display PEAR_Info output
$info->display();
?>
PEAR_Info::packageInstalled
PEAR_Info::packageInstalled() – Check if a package is installed
Synopsis
require_once 'PEAR/Info.php';
boolean PEAR_Info::packageInstalled (
string $name
, string $version
= null
, string $channel
= null
, string $user_file
= ''
, string $system_file
= ''
)
Description
Simple function to check if a package is installed under user or system PEAR installation. Minimal version and channel info are supported.
Parameter
-
string
$name -
Package name
-
string
$version -
(optional) The minimal version that should be installed
-
string
$channel -
(optional) The package channel distribution
-
string
$user_file -
(optional) file to read PEAR user-defined options from
-
string
$system_file -
(optional) file to read PEAR system-wide defaults from
Since
since version 1.6.0 (2005-01-03)
Throws
throws no exceptions thrown
Note
This function should be called statically.
Example
<?php
require_once 'PEAR/Info.php';
$res = PEAR_Info::packageInstalled('Role_Web', '1.1.0', 'pearified');
if ($res) {
print "Package pearified/Role_Web 1.1.0 or greater is installed \n";
} else {
print "Package pearified/Role_Web is not yet installed \n";
}
$res = PEAR_Info::packageInstalled('PEAR_PackageFileManager');
if ($res) {
print "Package pear/PEAR_PackageFileManager is installed \n";
} else {
print "Package pear/PEAR_PackageFileManager is not yet installed \n";
}
?>
PEAR_Info::pearImage
PEAR_Info::pearImage() – Display the PEAR logo
Synopsis
require_once 'PEAR/Info.php';
void
PEAR_Info::pearImage
(
)
Description
Display the PEAR logo (gif image) on browser output
Throws
throws no exceptions thrown
Since
since version 1.0.1 (2003-04-24)
Note
This function can not be called statically.
PEAR_Info::setProxy
PEAR_Info::setProxy() – Sets PEAR HTTP Proxy Server Address
Synopsis
require_once 'PEAR/Info.php';
boolean PEAR_Info::setProxy (
string $proxy
)
Description
Sets http_proxy config setting at runtime.
Since version 1.7.0RC1, it become unnecessary, unless you don't want to use the http_proxy config setting of your PEAR config file.
Parameter
-
string
$proxy -
PEAR HTTP Proxy Server Address
Since
since version 1.0.6 (2003-05-11)
Throws
throws no exceptions thrown
Note
This function should be called statically.
Return value
boolean - TRUE if the http proxy server address was set successfully, FALSE otherwise.
PEAR_Info::setStyleSheet
PEAR_Info::setStyleSheet() – Sets the custom style sheet to use your own styles
Synopsis
require_once 'PEAR/Info.php';
boolean PEAR_Info::setStyleSheet (
string $css
= null
)
Description
Sets the custom style sheet (colors, sizes) to applied to PEAR_Info output. If you don't give any parameter, you'll then apply again the default style.
Parameter
-
string
$css -
(optional) File to read user-defined styles from
Throws
throws no exceptions thrown
Since
since version 1.7.0RC1 (2007-07-01)
Note
This function can not be called statically.
If you don't want to have any style applied, then build an empty style sheet (css file) and give it as function parameter (See example below).
Return value
boolean - TRUE if custom styles, FALSE if default styles applied.
Example
<?php
// require the PEAR_Info file
require_once 'PEAR/Info.php';
// Create PEAR_Info object
$info = new PEAR_Info();
// set your own styles, rather than use the default stylesheet
$info->setStyleSheet(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'blueskin.css');
// don't use any style (empty.css is an empty file)
//$info->setStyleSheet(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'empty.css');
// Display PEAR_Info output
$info->display();
?>
PEAR_Info::show
PEAR_Info::show() – Shows PEAR_Info output
Synopsis
require_once 'PEAR/Info.php';
void PEAR_Info::show (
)
Description
Displays PEAR_Info output depending of style applied (style sheet).
Deprecated
deprecated use display() instead
Throws
throws no exceptions thrown
Since
since version 1.0.1 (2003-04-24)
Note
This function can not be called statically.
See
PEAR_Info::toHtml
PEAR_Info::toHtml() – Returns PEAR_Info output (html code)
Synopsis
require_once 'PEAR/Info.php';
string PEAR_Info::toHtml (
)
Description
Returns html code. This code is XHTML 1.1 compliant since version 1.7.0
Throws
throws no exceptions thrown
Since
since version 1.7.0RC1 (2007-07-01)
Note
This function can not be called statically.