Skip to content

Instantly share code, notes, and snippets.

@kenguest
Last active September 29, 2015 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenguest/1671361 to your computer and use it in GitHub Desktop.
Save kenguest/1671361 to your computer and use it in GitHub Desktop.
Check if certain PEAR packages of a specific version are installed.
// Check if certain PEAR packages of a specific version are installed.
// Originally posted as a comment to http://xn--9bi.net/2007/10/13/pear-list/
<?php
require 'PEAR/Registry.php';
$reg = new PEAR_Registry;
define("NAME", 0);
define("VERSION", 1);
$packages = array(
array("PEAR", "1.6.2"),
array("Date", "1.4.7"),
array("Date_Holidays", "0.17.1"),
array("Validate_IE", "0.3.1")
);
foreach ($packages as $package) {
var_dump($package);
$pkg = $reg->getPackage($package[NAME]);
$version = $pkg->getVersion();
echo "{$package[NAME]} – {$package[VERSION]} – ",
version_compare($version, $package[VERSION], '>=') ? 'OK': 'BAD', "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment