![]() PHP_CompatInfo : The Definitive Guide
|
Parsing a full directory, recursively or not, is no more difficult than detect PHP version of a single file.
This new example is based on auto detection of HTML_AJAX 0.5.0 distribution. As we will see, basic detection is not accurate as it should be. But with some options we can get the real result (PHP min = 4.2.1).
Here is now the simple detection script.
<?php require_once 'PHP/CompatInfo.php'; $info = new PHP_CompatInfo(); $path_to_dir = 'c:\pear\html\HTML_Ajax-0.5.0'; $res = $info->parseDir($path_to_dir); echo '<pre>'; var_dump($res); echo '</pre>'; ?>
And a chunk of raw results we got :
array(61) { ["ignored_files"]=> array(0) { } ["max_version"]=> string(0) "" ["version"]=> string(5) "5.0.0" ["extensions"]=> array(6) { [0]=> string(8) "mbstring" [1]=> string(4) "pcre" [2]=> string(6) "domxml" [3]=> string(4) "curl" [4]=> string(7) "sockets" [5]=> string(7) "session" } ["constants"]=> array(1) { [0]=> string(8) "__FILE__" } ["c:\pear\html\HTML_Ajax-0.5.0\examples\xml_usage.php"]=> array(4) { ["max_version"]=> string(0) "" ["version"]=> string(5) "3.0.0" ["extensions"]=> array(0) { } ["constants"]=> array(0) { } } [... more ...] }
It means that we need at least PHP 5.0.0 to run HTML_Ajax 0.5.0 with PHP extensions mbstring, pcre, domxml, curl, sockets, session loaded. Of course this is not the REAL and TRUE result. We will see later how to fix it and improve accuracy detection.
![]() |
Tip |
---|---|
In raw output, you get for each script parsed the same results as if you run
PHP_CompatInfo::parseFile() for all these files.
|
If we try again to detect the same distribution untar directory, the command to run will be:
pcicmd -d c:\pear\html\HTML_Ajax-0.5.0
And chunk of results give:
+----------------------------------+---------+------------+------------------+ | Path | Version | Extensions | Constants/Tokens | +----------------------------------+---------+------------+------------------+ | [...]\* | 5.0.0 | mbstring | __FILE__ | | | | pcre | | | | | domxml | | | | | curl | | | | | sockets | | | | | session | | +----------------------------------+---------+------------+------------------+ | [...]\examples\xml_usage.php | 3.0.0 | | | +----------------------------------+---------+------------+------------------+ | [...]\examples\xmlserver.php | 3.0.0 | | | +----------------------------------+---------+------------+------------------+ | [...]\examples\tests\ (+) | 3.0.0 | | | | test_speed.php | | | | +----------------------------------+---------+------------+------------------+ | [...]\examples\tests\ (+) | 3.0.0 | | | | test_priority.php | | | | +----------------------------------+---------+------------+------------------+ [... more ...] +----------------------------------+---------+------------+------------------+ | [...]\AJAX\Action.php | 4.0.4 | | | +----------------------------------+---------+------------+------------------+
![]() |
Note |
---|---|
[...] replace the full path to directory given by
-d option, while (+) indicates that path to a file has been splitted (to limit output to 80 columns).
|
PHP_CompatInfo : The Definitive Guide | v 1.4.0 : September 27, 2006 |