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 3.2.0 build ...

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.
  --profile           Display timing and memory usage information.

Available commands:
  help               Displays help for a command
  list               Lists commands
plugin
  plugin:list        List all plugins installed.
provider
  provider:display   Show source of a file in a data source.
  provider:list      List all data source providers.
  provider:show      Show list of files in a data source.
reference
  reference:list     List all references supported.
  reference:show     Show information about a reference.
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

 [Json Configuration]
 No plugins detected.
With only Analyser plugin configured, you will get
$ phpcompatinfo plugin:list

 Plugin Name Plugin Class                                    Events Subscribed
 Analyser    Bartlett\Reflect\Plugin\Analyser\AnalyserPlugin reflect.complete
provider:list
List all data source providers configured in source-providers section of your phpcompatinfo.json config file.
Result may vary depending of your current directory, but you will get something like
$ phpcompatinfo provider:list

 Source Alias   Files
 .      current     46
provider:show
Show list of files corresponding to the (Symfony) Finder rules defined.
With Reflect source files
$ phpcompatinfo provider:show .

Possible alternative

$ phpcompatinfo provider:show --alias current
 Source                                                  Files
 .                                                       46
 Relative Path Name                                      Date                      Size
 Bartlett\Reflect\Analyser\AbstractAnalyser.php          2014-02-03T17:25:07+01:00    3475
 Bartlett\Reflect\Analyser\AnalyserInterface.php         2014-02-03T17:26:50+01:00     835
 Bartlett\Reflect\Analyser\StructureAnalyser.php         2014-02-23T17:31:16+01:00   12798

 <... more lines ...>
provider:display
Show source code of a file in one of the data source identified.
With Bartlett\Reflect.php in the current data source
$ phpcompatinfo provider:display . Bartlett\Reflect.php

Possible alternative

$ phpcompatinfo provider:display --alias current Bartlett\Reflect.php
 Source
 .
 Relative Path Name Date Size
 Id    Token                          Line  Text
     0 T_OPEN_TAG                         1 <?php
     1 T_DOC_COMMENT                      2 /** * Reflect * Reverse-engineer
     2 T_WHITESPACE                      15
     3 T_NAMESPACE                       17 namespace
     4 T_WHITESPACE                      17
     5 T_STRING                          17 Bartlett
     6 T_SEMICOLON                       17 ;

 <... more lines ...>
reference:list
Show the list of all references supported in this version.
$ phpcompatinfo reference:list
 References     Version     Loaded
 amqp           1.4.0       1.4.0
 apc            3.1.13      4.0.6
 apcu           4.0.4       4.0.6

 <... more lines ...>

 Zend OPcache   7.0.4-devFE 7.0.4-devFE
 zip            1.12.4      1.12.4
 zlib           2.0         2.0
 Total [100]
  • Loaded version is referenced only if the corresponding extension is loaded from your php.ini configuration file.

  • For PHP extensions that are always enabled by default, the versions (current and loaded) depends of your platform.

reference:show
Introspection of a reference (case insensitive)
For example, with apc reference
$ phpcompatinfo reference:show apc
List all elements of apc extension
 IniEntries                 REF EXT min/Max PHP min/Max
 apc.cache_by_default           3.0.0       4.3.0
 apc.canonicalize               3.1.1       5.1.0
 apc.coredump_unmap             3.0.19      4.3.0
 apc.enable_cli                 3.0.11      4.3.0
 apc.enabled                    2.0.0       4.0.0
 apc.file_md5                   3.1.1       5.1.0
 apc.file_update_protection     3.0.11      4.3.0
 apc.filters                    2.0.0       4.0.0
 apc.gc_ttl                     2.0.0       4.0.0
 apc.include_once_override      3.0.19      4.3.0
 apc.lazy_classes               3.1.12      5.1.0
 apc.lazy_functions             3.1.12      5.1.0
 apc.max_file_size              3.0.11      4.3.0
 apc.mmap_file_mask             2.0.0       4.0.0
 apc.num_files_hint             2.0.0       4.0.0
 apc.optimization               2.0.0       4.0.0
 apc.preload_path               3.1.1       5.1.0
 apc.report_autofilter          3.0.11      4.3.0
 apc.rfc1867                    3.0.19      4.3.0
 apc.rfc1867_freq               3.0.19      4.3.0
 apc.rfc1867_name               3.0.19      4.3.0
 apc.rfc1867_prefix             3.0.19      4.3.0
 apc.rfc1867_ttl                3.1.1       5.1.0
 apc.serializer                 3.1.12      5.1.0
 apc.shm_segments               2.0.0       4.0.0
 apc.shm_size                   2.0.0       4.0.0
 apc.shm_strings_buffer         3.1.12      5.1.0
 apc.slam_defense               3.0.0       4.3.0
 apc.stat                       3.0.11      4.3.0
 apc.stat_ctime                 3.0.19      4.3.0
 apc.ttl                        3.0.0       4.3.0
 apc.use_request_time           3.1.12      5.1.0
 apc.user_entries_hint          3.0.0       4.3.0
 apc.user_ttl                   3.0.0       4.3.0
 apc.write_lock                 3.0.11      4.3.0
 Total [35]
 Constants            REF EXT min/Max PHP min/Max
 APC_BIN_VERIFY_CRC32     3.1.4       5.1.0
 APC_BIN_VERIFY_MD5       3.1.4       5.1.0
 APC_ITER_ALL             3.1.1       5.1.0
 APC_ITER_ATIME           3.1.1       5.1.0
 APC_ITER_CTIME           3.1.1       5.1.0
 APC_ITER_DEVICE          3.1.1       5.1.0
 APC_ITER_DTIME           3.1.1       5.1.0
 APC_ITER_FILENAME        3.1.1       5.1.0
 APC_ITER_INODE           3.1.1       5.1.0
 APC_ITER_KEY             3.1.1       5.1.0
 APC_ITER_MD5             3.1.1       5.1.0
 APC_ITER_MEM_SIZE        3.1.1       5.1.0
 APC_ITER_MTIME           3.1.1       5.1.0
 APC_ITER_NONE            3.1.1       5.1.0
 APC_ITER_NUM_HITS        3.1.1       5.1.0
 APC_ITER_REFCOUNT        3.1.1       5.1.0
 APC_ITER_TTL             3.1.1       5.1.0
 APC_ITER_TYPE            3.1.1       5.1.0
 APC_ITER_VALUE           3.1.1       5.1.0
 APC_LIST_ACTIVE          3.1.1       5.1.0
 APC_LIST_DELETED         3.1.1       5.1.0
 Total [21]
 Functions            REF EXT min/Max PHP min/Max
 apc_add                  3.0.13      4.3.0
 apc_bin_dump             3.1.4       5.1.0
 apc_bin_dumpfile         3.1.4       5.1.0
 apc_bin_load             3.1.4       5.1.0
 apc_bin_loadfile         3.1.4       5.1.0
 apc_cache_info           2.0.0       4.0.0
 apc_cas                  3.1.1       5.1.0
 apc_clear_cache          2.0.0       4.0.0
 apc_compile_file         3.0.13      4.3.0
 apc_dec                  3.1.1       5.1.0
 apc_define_constants     3.0.0       4.3.0
 apc_delete               3.0.0       4.3.0
 apc_delete_file          3.1.1       5.1.0
 apc_exists               3.1.4       5.1.0
 apc_fetch                3.0.0       4.3.0
 apc_inc                  3.1.1       5.1.0
 apc_load_constants       3.0.0       4.3.0
 apc_sma_info             2.0.0       4.0.0
 apc_store                3.0.0       4.3.0
 Total [19]
 Classes     REF EXT min/Max PHP min/Max
 APCIterator     3.1.1       5.1.0
 Total [1]
List all elements of apc extension that requires at least PHP 5.1
$ phpcompatinfo reference:show --php=">= 5.1.0" apc

 IniEntries             REF EXT min/Max PHP min/Max
 apc.canonicalize           3.1.1       5.1.0
 apc.file_md5               3.1.1       5.1.0
 apc.lazy_classes           3.1.12      5.1.0
 apc.lazy_functions         3.1.12      5.1.0
 apc.preload_path           3.1.1       5.1.0
 apc.rfc1867_ttl            3.1.1       5.1.0
 apc.serializer             3.1.12      5.1.0
 apc.shm_strings_buffer     3.1.12      5.1.0
 apc.use_request_time       3.1.12      5.1.0
 Total [9/35]
 Constants            REF EXT min/Max PHP min/Max
 APC_BIN_VERIFY_CRC32     3.1.4       5.1.0
 APC_BIN_VERIFY_MD5       3.1.4       5.1.0
 APC_ITER_ALL             3.1.1       5.1.0
 APC_ITER_ATIME           3.1.1       5.1.0
 APC_ITER_CTIME           3.1.1       5.1.0
 APC_ITER_DEVICE          3.1.1       5.1.0
 APC_ITER_DTIME           3.1.1       5.1.0
 APC_ITER_FILENAME        3.1.1       5.1.0
 APC_ITER_INODE           3.1.1       5.1.0
 APC_ITER_KEY             3.1.1       5.1.0
 APC_ITER_MD5             3.1.1       5.1.0
 APC_ITER_MEM_SIZE        3.1.1       5.1.0
 APC_ITER_MTIME           3.1.1       5.1.0
 APC_ITER_NONE            3.1.1       5.1.0
 APC_ITER_NUM_HITS        3.1.1       5.1.0
 APC_ITER_REFCOUNT        3.1.1       5.1.0
 APC_ITER_TTL             3.1.1       5.1.0
 APC_ITER_TYPE            3.1.1       5.1.0
 APC_ITER_VALUE           3.1.1       5.1.0
 APC_LIST_ACTIVE          3.1.1       5.1.0
 APC_LIST_DELETED         3.1.1       5.1.0
 Total [21/21]
 Functions        REF EXT min/Max PHP min/Max
 apc_bin_dump         3.1.4       5.1.0
 apc_bin_dumpfile     3.1.4       5.1.0
 apc_bin_load         3.1.4       5.1.0
 apc_bin_loadfile     3.1.4       5.1.0
 apc_cas              3.1.1       5.1.0
 apc_dec              3.1.1       5.1.0
 apc_delete_file      3.1.1       5.1.0
 apc_exists           3.1.4       5.1.0
 apc_inc              3.1.1       5.1.0
 Total [9/19]
 Classes     REF EXT min/Max PHP min/Max
 APCIterator     3.1.1       5.1.0
 Total [1/1]
List ini directives of apc extension, that require only PHP 4.3
$ phpcompatinfo reference:show --ini --php="== 4.3.0" apc

 IniEntries                 REF EXT min/Max PHP min/Max
 apc.cache_by_default           3.0.0       4.3.0
 apc.coredump_unmap             3.0.19      4.3.0
 apc.enable_cli                 3.0.11      4.3.0
 apc.file_update_protection     3.0.11      4.3.0
 apc.include_once_override      3.0.19      4.3.0
 apc.max_file_size              3.0.11      4.3.0
 apc.report_autofilter          3.0.11      4.3.0
 apc.rfc1867                    3.0.19      4.3.0
 apc.rfc1867_freq               3.0.19      4.3.0
 apc.rfc1867_name               3.0.19      4.3.0
 apc.rfc1867_prefix             3.0.19      4.3.0
 apc.slam_defense               3.0.0       4.3.0
 apc.stat                       3.0.11      4.3.0
 apc.stat_ctime                 3.0.19      4.3.0
 apc.ttl                        3.0.0       4.3.0
 apc.user_entries_hint          3.0.0       4.3.0
 apc.user_ttl                   3.0.0       4.3.0
 apc.write_lock                 3.0.11      4.3.0
 Total [18/35]
The possible operators are: <, <=, >, >=, ==, =, !=, <>.

When the Analyser plugin is installed, following lines added into analysers section

    {
        "name": "Analyser",
        "class": "Bartlett\\Reflect\\Plugin\\Analyser\\AnalyserPlugin"
    }

you will get two additionnal commands.

analyser:list
List all analysers configured in analysers section of your phpcompatinfo.json config file.
Without analysers, you will get
$ phpcompatinfo analyser:list

 [Json Configuration]
 No analysers detected.
With only Analyser plugin configured, you will get
$ phpcompatinfo analyser:list

 Analyser Name Analyser Class
 Class         Bartlett\CompatInfo\Analyser\ClassAnalyser
 Constant      Bartlett\CompatInfo\Analyser\ConstantAnalyser
 Extension     Bartlett\CompatInfo\Analyser\ExtensionAnalyser
 Function      Bartlett\CompatInfo\Analyser\FunctionAnalyser
 Interface     Bartlett\CompatInfo\Analyser\InterfaceAnalyser
 Namespace     Bartlett\CompatInfo\Analyser\NamespaceAnalyser
 Structure     Bartlett\Reflect\Analyser\StructureAnalyser
 Summary       Bartlett\CompatInfo\Analyser\SummaryAnalyser
 Trait         Bartlett\CompatInfo\Analyser\TraitAnalyser
analyser:run
Parse a data source and display results. May wary depending of the data source and analyser used.
With structure analyser and the Reflect source code, you will get something like
$ phpcompatinfo analyser:run .

Possible alternative

$ phpcompatinfo analyser:run --alias current
Data Source Analysed

Directories                                          8
Files                                              123


Summary Analysis

Summary
  Extensions                                        10
  Namespaces                                         8
  Interfaces                                         4
  Traits                                             0
  Classes                                          132
  Methods                                          732
  Functions                                          3
  Constants                                         11
  Internal Functions                                43

Versions
  PHP min                                        5.3.7
  PHP max

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.

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.