PEAR logo

PHP_CompatInfo : The Definitive Guide

Chapter 3. FAQ - Frequently Asked Questions

3.1. General questions
3.1.1. What does it cost ?
3.1.2. Do you offer support ?
3.1.3. I found a bug, what shall i do ?
3.1.4. What is PEAR ?
3.2. How to do
3.2.1. I have a compatible PHP4/5 application with optional PHP5 code. How to ignore only PHP 5 code ?
3.3. About new API 1.8.0
3.3.1. I don't want to have result (PHP array dump) display on the standard output
3.3.2. I want to know what is the status of parsing my data source.

3.1. General questions

3.1.1. What does it cost ?
3.1.2. Do you offer support ?
3.1.3. I found a bug, what shall i do ?
3.1.4. What is PEAR ?
3.1.1.

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 license

3.1.2.

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.

3.1.3.

I found a bug, what shall i do ?

You can report it with the bug tracker at PEAR.

3.1.4.

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.

3.2. How to do

3.2.1. I have a compatible PHP4/5 application with optional PHP5 code. How to ignore only PHP 5 code ?
3.2.1.

I have a compatible PHP4/5 application with optional PHP5 code. How to ignore only PHP 5 code ?

If you want to ignore all PHP5 code (functions, constants, extensions), you only need to add a line on your parsing (file, directory, string) options: "ignore_versions". In this example all PHP 5.0.0 to 5.2.0 code will be ignored when parsing current directory.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.  
  4. $dir = dirname(__FILE__);
  5. $options = array('ignore_versions' => array('5.0.0', '5.2.0'));
  6.  
  7. $pci = new PHP_CompatInfo();
  8. $res = $pci->parseDir($dir, $options);
  9. var_dump($res);
  10. ?>

3.3. About new API 1.8.0

3.3.1. I don't want to have result (PHP array dump) display on the standard output
3.3.2. I want to know what is the status of parsing my data source.
3.3.1.

I don't want to have result (PHP array dump) display on the standard output

Even if it's the new behavior of API 1.8.0, you can still consumes all output events with the Null renderer. Give the null value (case insensitive), as first parameter to the class constructor.

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.  
  4. $pci = new PHP_CompatInfo('null');
  5.  
  6. $res = $pci->parseData($datasource);
  7.  
  8. // display results is only produced by the line below
  9. var_dump($res);
  10. ?>
3.3.2.

I want to know what is the status of parsing my data source.

For a single file, it's not necessary to have a progress bar or a message wait. But when you parse a directory with many subdirectories and files, it may take some time.

Depending of interface you're running (CLI or Web) you've two ways to display a progress bar or a message wait.

[Warning] Warning

If you specify a progress bar to wait and you don't have PEAR::Console_ProgressBar package installed, default use standard text messages (no error stop the process).

Wait while parsing data source ...
Wait while parsing file "C:\wamp\tmp\Services_W3C_CSSValidator-0.1.0\CSSValidator.php"

On CLI with pci command, give the -p|--progress switch with either bar (for a progress bar), or text (for a simple text message).

pci --summarize --progress bar --dir C:\Temp\beehiveforum082\forum

On CLI without pci command, use the second parameter (driver specific options) of class constructor. Give progress key with bar (for a progress bar), or text (for a simple text message). And don't forget to de-activate silent mode (default is on for behavior backward compatibility).

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.  
  4. $driverType    = 'csv';
  5. $driverOptions = array('silent' => false, 'progress' => 'bar');
  6.  
  7. $pci = new PHP_CompatInfo($driverType, $driverOptions);
  8. ?>

It will produce something like:

-  79/419 files [====>-----------------]  18.85% Elapsed Time: 00:28.93

For Web SAPI see the full example available in distribution into examples directory named pci180_parsefolder_tohtml.php. It used the PEAR::HTML_Progress2 package to produce a progress bar with COMET method (not AJAX).

PHP_CompatInfo : The Definitive Guide v 1.8.0 : August 1, 2008