For this you need to use the PEAR_Registry class (as the PEAR script itself). Read the Adam Harvey blog post โ pear โ list โ 3 years ago - all the details / examples you need.
include 'PEAR/Registry.php'; $reg = new PEAR_Registry; foreach ($reg->listPackages() as $package) { print "$package\n"; }
If you need this to check the specific versions of each package, you can use something in the following example, which I presented in a comment on this blog post:
<?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) { $pkg = $reg->getPackage($package[NAME]); $version = $pkg->getVersion(); echo "{$package[NAME]} โ {$package[VERSION]} โ "; echo version_compare($version, $package[VERSION], '>=') ? 'OK': 'BAD', "\n"; } ?>
If you need to copy and paste this, then you might be better off using the version https://gist.github.com/kenguest/1671361 .
source share