The Command-Line

The command-line interface is the easiest way to try and learn the basic CompatInfo features.

For all users.

Command-Line Options

Without plugins and analysers sections in your phpcompatinfo.json configuration file, when you invoke the phpcompatinfo command, you should obtain the following commands and options :

        _            ____                            _   ___        __
  _ __ | |__  _ __  / ___|___  _ __ ___  _ __   __ _| |_|_ _|_ __  / _| ___
 | '_ \| '_ \| '_ \| |   / _ \| '_ ` _ \| '_ \ / _` | __|| || '_ \| |_ / _ \
 | |_) | | | | |_) | |__| (_) | | | | | | |_) | (_| | |_ | || | | |  _| (_) |
 | .__/|_| |_| .__/ \____\___/|_| |_| |_| .__/ \__,_|\__|___|_| |_|_|  \___/
 |_|         |_|                        |_|

phpCompatInfo version 4.4.0 DB built Jul 11 2015 09:22:57 CEST

Usage:
 [options] command [arguments]

Options:
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question
 --no-plugins          Disables all plugins.
 --profile             Display timing and memory usage information.
 --progress            Show progress bar.
 --output              Write results to file or URL.
 --manifest            Show which versions of dependencies are bundled.

Available commands:
 help                  Displays help for a command
 list                  Lists commands
analyser
 analyser:list         List all analysers available.
 analyser:run          Analyse a data source and display results.
cache
 cache:clear           Clear cache (any adapter and backend).
config
 config:validate       Validates a JSON configuration file.
diagnose
 diagnose:run          Diagnoses the system to identify common errors.
diagram
 diagram:class         Generates diagram about a user class present in a data source.
 diagram:package       Generates diagram about namespaces in a data source.
plugin
 plugin:list           List all plugins installed.
reference
 reference:list        List all references supported.
 reference:show        Show information about a reference.
reflection
 reflection:class      Reports information about a user class present in a data source.
 reflection:function   Reports information about a user function present in a data source.

Auto-Diagnose:

Checking php settings:
- Requires PHP 5.3.2 or better OK
- php.ini file loaded C:\UwAmp\bin\php\php-5.6.9\php.ini
- date extension loaded YES
- json extension loaded YES
- pcre extension loaded YES
- phar extension loaded YES
- reflection extension loaded YES
- spl extension loaded YES
- tokenizer extension loaded YES
config:validate
Validates an optional JSON config file.
$ phpcompatinfo config:validate
"/etc/phpcompatinfo.json" config file is valid.
diagnose:run
Diagnoses the system to identify common errors.
$ phpcompatinfo diagnose:run
Checking php settings:
- Requires PHP 5.3.2 or better OK
- php.ini file loaded C:\UwAmp\bin\php\php-5.6.9\php.ini
- date extension loaded YES
- json extension loaded YES
- pcre extension loaded YES
- phar extension loaded YES
- reflection extension loaded YES
- spl extension loaded YES
- tokenizer extension loaded YES
Use verbose level 2 for more details, and level 3 to get raw response
diagram:class
Generates diagram about a user class present in a data source.
$ phpcompatinfo diagram:class Bartlett\Reflect\Plugin\LogPlugin ./src
diagram:package
Generates diagram about namespaces in a data source.
$ phpcompatinfo diagram:package --engine=graphviz ./src
plugin:list
List all plugins configured (and correctly installed) in plugins section of your phpcompatinfo.json config file.
Without plugins, you will get
$ phpcompatinfo plugin:list
No plugin installed.
With only Cache plugin configured, you will get
$ phpcompatinfo plugin:list
 Plugin Class                           Events Subscribed
 Bartlett\Reflect\Plugin\CachePlugin    reflect.progress
                                        reflect.success
                                        reflect.complete
analyser:list
List all analysers configured in analysers section of your phpcompatinfo.json config file, and available by default.
With only default analysers, you will get
$ phpcompatinfo analyser:list
 Analyser Name Analyser Class
 loc           Bartlett\Reflect\Analyser\LocAnalyser
 reflection    Bartlett\Reflect\Analyser\ReflectionAnalyser
 structure     Bartlett\Reflect\Analyser\StructureAnalyser
 compatibility Bartlett\CompatInfo\Analyser\CompatibilityAnalyser
analyser:run
Parse a data source and display results. May vary depending of the data source and analyser used.
With compatibility analyser and the CompatInfo source code, you will get something like
$ phpcompatinfo analyser:run .
Possible alternative (if you use the default json config file)
$ phpcompatinfo analyser:run --alias current
Data Source Analysed

Directories                                         11
Files                                               13

Extensions Analysis

    Extension Matches REF      EXT min/Max PHP min/Max PHP all
    Core              Core                 4.0.0       5.3.0
    PDO               PDO      5.1.0       5.1.0
    curl              curl     4.0.2       4.0.2
    intl              intl     2.0.0b1     5.3.7
    libxml            libxml   5.1.0       5.1.0
    openssl           openssl  5.2.0       5.2.0
    pcre              pcre     4.0.0       4.0.0
    spl               spl      5.1.0       5.1.0
    standard          standard 4.0.0       4.0.0       5.3.2
    Total [9]                              5.3.7

Namespaces Analysis

    Namespace                             Matches REF  EXT min/Max PHP min/Max PHP all
    +global                                       Core             4.0.0
    Bartlett\CompatInfo                           user             5.3.0
    Bartlett\CompatInfo\Analyser                  user             5.3.0
    Bartlett\CompatInfo\Api                       user             5.3.0       5.3.2
    Bartlett\CompatInfo\Api\V3                    user             5.3.0
    Bartlett\CompatInfo\Collection                user             5.3.0
    Bartlett\CompatInfo\Console                   user             5.3.0
    Bartlett\CompatInfo\Console\Formatter         user             5.3.0
    Bartlett\CompatInfo\Output                    user             5.3.0
    Bartlett\CompatInfo\PhpParser                 user             5.3.0
    Bartlett\CompatInfo\Reference                 user             5.3.0
    Bartlett\CompatInfo\Util                      user             5.3.0
    Total [12]                                                     5.3.0       5.3.2

Interfaces Analysis

    Interface                                        Matches REF  EXT min/Max PHP min/Max PHP all
    Bartlett\CompatInfo\Reference\ReferenceInterface 1       user             5.3.0
    Total [1]                                                                 5.3.0

No trait found

Classes Analysis

    Class                                                              Matches REF  EXT min/Max PHP min/Max PHP all
    Bartlett\CompatInfo\Analyser\CompatibilityAnalyser                         user             5.3.0
    Bartlett\CompatInfo\Api\Reference                                          user             5.3.0       5.3.2
    Bartlett\CompatInfo\Api\V3\Reference                                       user             5.3.0
    Bartlett\CompatInfo\Collection\ReferenceCollection                 1       user             5.3.0
    Bartlett\CompatInfo\Console\Application                                    user             5.3.0
    Bartlett\CompatInfo\Console\Formatter\CompatibilityOutputFormatter         user             5.3.0
    Bartlett\CompatInfo\Environment                                    4       user             5.3.0
    Bartlett\CompatInfo\Output\Reference                                       user             5.3.0
    Bartlett\CompatInfo\PhpParser\ConditionalCodeNodeProcessor         1       user             5.3.0
    Bartlett\CompatInfo\Reference\ExtensionFactory                     2       user             5.3.0
    Bartlett\CompatInfo\Reference\SqliteStorage                        1       user             5.3.0
    Bartlett\CompatInfo\Util\Version                                   10      user             5.3.0
  U Bartlett\Reflect\Analyser\AbstractAnalyser                         1       user             5.3.0
  U Bartlett\Reflect\Api\BaseApi                                       1       user             5.3.0
  U Bartlett\Reflect\Api\V3\Common                                     1       user             5.3.0
  U Bartlett\Reflect\Console\Application                               1       user             5.3.0
  U Bartlett\Reflect\Console\Formatter\OutputFormatter                 2       user             5.3.0
  U Bartlett\Reflect\PhpParser\NodeProcessorAbstract                   1       user             5.3.0
  U Doctrine\Common\Collections\AbstractLazyCollection                 1       user             5.3.0
  U Doctrine\Common\Collections\ArrayCollection                        1       user             5.3.0
    PDO                                                                2       PDO  5.1.0       5.1.0
  U PhpParser\Node                                                     21      user             5.3.0
  U PhpParser\Node\Name                                                1       user             5.3.0
    RuntimeException                                                   1       spl  5.1.0       5.1.0
  U Symfony\Component\Console\Helper\TableSeparator                    3       user             5.3.0
  U Symfony\Component\Console\Output\OutputInterface                   4       user             5.3.0
    parent                                                             5       Core 5.0.0       5.0.0
    self                                                               11      Core 5.0.0       5.0.0
    stdClass                                                           1       Core 4.0.0       4.0.0
    Total [29]                                                                                  5.3.0       5.3.2

Functions Analysis

    Function                    Matches REF      EXT min/Max PHP min/Max
    array_key_exists            7       standard 4.0.7       4.0.7
    array_map                   2       standard 4.0.6       4.0.6
    array_merge                 3       standard 4.0.0       4.0.0
    array_pop                   6       standard 4.0.0       4.0.0
    array_shift                 2       standard 4.0.0       4.0.0
    array_slice                 1       standard 4.0.0       4.0.0
    array_values                1       standard 4.0.0       4.0.0
    closure-73-75                       user                 5.3.0
    copy                        1       standard 4.0.0       4.0.0
    count                       14      standard 4.0.0       4.0.0
 C  curl_version                1       curl     4.0.2       4.0.2
    defined                     4       Core     4.0.0       4.0.0
    dirname                     3       standard 4.0.0       4.0.0
    each                        2       Core     4.0.0       4.0.0
    end                         3       standard 4.0.0       4.0.0
    explode                     2       standard 4.0.0       4.0.0
    extension_loaded            1       Core     4.0.0       4.0.0
    file_exists                 2       standard 4.0.0       4.0.0
    function_exists             1       Core     4.0.0       4.0.0
    in_array                    10      standard 4.0.0       4.0.0
    is_array                    1       standard 4.0.0       4.0.0
    is_callable                 1       standard 4.0.6       4.0.6
    is_string                   10      standard 4.0.0       4.0.0
    ksort                       3       standard 4.0.0       4.0.0
    ltrim                       1       standard 4.0.0       4.0.0
    mkdir                       1       standard 4.0.0       4.0.0
    phpversion                  2       standard 4.0.0       4.0.0
    preg_match                  2       pcre     4.0.0       4.0.0
    sha1_file                   2       standard 4.3.0       4.3.0
    sprintf                     26      standard 4.0.0       4.0.0
    str_replace                 1       standard 4.0.0       4.0.0
    strcasecmp                  4       Core     4.0.0       4.0.0
    stream_resolve_include_path 1       standard 5.3.2       5.3.2
    strpos                      2       standard 4.0.0       4.0.0
    strtolower                  1       standard 4.0.0       4.0.0
    substr                      2       standard 4.0.0       4.0.0
    sys_get_temp_dir            1       standard 5.2.1       5.2.1
    ucfirst                     5       standard 4.0.0       4.0.0
    version_compare             9       standard 4.0.7       4.0.7
    Total [39]                                               5.3.2

Constants Analysis

    Constant               Matches REF     EXT min/Max PHP min/Max
 C  INTL_ICU_VERSION       2       intl    2.0.0b1     5.3.7
    LIBXML_DOTTED_VERSION  1       libxml  5.1.0       5.1.0
    LIBXML_VERSION         1       libxml  5.1.0       5.1.0
 C  OPENSSL_VERSION_NUMBER 1       openssl 5.2.0       5.2.0
 C  OPENSSL_VERSION_TEXT   1       openssl 5.2.0       5.2.0
    PHP_EOL                5       Core    4.3.10      4.3.10
    PHP_VERSION            4       Core    4.0.0       4.0.0
    __DIR__                1       Core    5.3.0       5.3.0
    false                  14      Core    4.0.0       4.0.0
    null                   15      Core    4.0.0       4.0.0
    true                   10      Core    4.0.0       4.0.0
    Total [11]                                         5.3.0

Conditions Analysis

    Condition                       Matches REF     EXT min/Max PHP min/Max
    defined(INTL_ICU_VERSION)       2       intl    2.0.0b1     5.3.7
    defined(OPENSSL_VERSION_NUMBER) 1       openssl 5.2.0       5.2.0
    defined(OPENSSL_VERSION_TEXT)   1       openssl 5.2.0       5.2.0
    function_exists(curl_version)   1       curl    4.0.2       4.0.2
    Total [4]                                                   5.3.7

Requires PHP 5.3.2 (min), PHP 5.3.2 (all)
The PHP all column tell us which version is required when all code features are used
Since version 4.2, you can filter results with a user closure
$ phpcompatinfo analyser:run --filter=YourFilters.php .
Learn more on developer’s guide
reflection:class
Reports information about a user class present in a data source.
With the CompatInfo source code (./src), and Bartlett\CompatInfo\Environment class
$ phpcompatinfo reflection:class Bartlett\CompatInfo\Environment ./src
Class [ <user> class Bartlett\CompatInfo\Environment ] {
  @@ C:\home\github\php-compat-info\src\Bartlett\CompatInfo\Environment.php 28 - 73

  - Constants [0] {
  }

  - Properties [0] {
  }

  - Methods [2] {
    Method [ <user> public method initRefDb ] {
      @@ C:\home\github\php-compat-info\src\Bartlett\CompatInfo\Environment.php 35 - 55

      - Parameters [0] {
      }
    }

    Method [ <user> public method versionRefDb ] {
      @@ C:\home\github\php-compat-info\src\Bartlett\CompatInfo\Environment.php 62 - 72

      - Parameters [0] {
      }
    }
  }
}

Summary

Let’s review what we’ve learned about the command-line interface :

  • It’s a Symfony Console Component that can be extended to infinite via plugins and analysers.

  • You can examine inside a reference and filters elements.

Next

For PHP developers only.

Read more
  • Want to learn more about CompatInfo architecture and /or you want to extends it to match your needs, have a look on developer’s guide.