Download

We distribute a PHP Archive (PHAR) that contains all required dependencies of PHP CompatInfo bundled in a single file.

Make it executable, and put it into your $PATH.

$ chmod +x phpcompatinfo-3.7.0.phar
$ mv phpcompatinfo-3.7.0.phar /usr/local/bin/phpcompatinfo

$ phpcompatinfo --version

You can also immediately use the PHAR after you have downloaded it.

$ wget http://bartlett.laurent-laville.org/get/phpcompatinfo-3.7.0.phar
$ php phpcompatinfo-3.7.0.phar --version

With both methods then you have this output :

phpCompatInfo version 3.7.0

Other alternative installations are possible. Please refer to the documentation for details on how to do this.

Configuration

With the minimalist JSON file phpcompatinfo.json
{
    "source-providers": [
        {
            "in": ". as current",
            "name": "/\\.(php|inc|phtml)$/"
        }
    ],
    "plugins": [
        {
            "name": "Analyser",
            "class": "Bartlett\\Reflect\\Plugin\\Analyser\\AnalyserPlugin"
        }
    ],
    "analysers" : [
        {
            "name": "Namespace",
            "class": "Bartlett\\CompatInfo\\Analyser\\NamespaceAnalyser"
        },
        {
            "name": "Extension",
            "class": "Bartlett\\CompatInfo\\Analyser\\ExtensionAnalyser"
        },
        {
            "name": "Interface",
            "class": "Bartlett\\CompatInfo\\Analyser\\InterfaceAnalyser"
        },
        {
            "name": "Trait",
            "class": "Bartlett\\CompatInfo\\Analyser\\TraitAnalyser"
        },
        {
            "name": "Class",
            "class": "Bartlett\\CompatInfo\\Analyser\\ClassAnalyser"
        },
        {
            "name": "Function",
            "class": "Bartlett\\CompatInfo\\Analyser\\FunctionAnalyser"
        },
        {
            "name": "Constant",
            "class": "Bartlett\\CompatInfo\\Analyser\\ConstantAnalyser"
        },
        {
            "name": "Summary",
            "class": "Bartlett\\CompatInfo\\Analyser\\SummaryAnalyser"
        },
        {
            "name": "Condition",
            "class": "Bartlett\\CompatInfo\\Analyser\\CodeCondAnalyser"
        }
    ]
}

Put it in your project’s folder. Alternative locations are possible. Please refer to the documentation for details on how to do this.

Structure

source-providers
this entry provide list of your data sources to parse.

Like CompatInfo always needs a JSON file to run, Remi Collet shared a workaround solution exposed here that allows to run :

$ phpcompatinfo analyser:run .
plugins
this entry list all plugins added to the core base code of PHP Reflect.
Don’t forget to add at least this default content, else the analyser:run and analyser:list commands wouldn’t be available.
analysers
this entry list all analysers that may be used with the analyser:run command.
Don’t miss it, else you could not run the analyser:run command.

Execution

With a default phpcompatinfo.json as detailed above, put in the src/ folder of the CompatInfo source code, and invoke the following command :

$ phpcompatinfo analyser:run .

and you should obtain something like this :

Data Source Analysed

Directories                                          7
Files                                              127

Global Analysis

                    Count Cond PHP min Elements highlight
 Extensions         11    4    5.3.0   Core
 Namespaces         14    0    5.3.0   Bartlett\CompatInfo\Reference
 Interfaces         3     0    5.3.0   Bartlett\CompatInfo\Reference\ReferenceInterface
 Traits             0     0
 Classes            140   1    5.3.0   Bartlett\CompatInfo\Reference\Extension\RarExtension
 User Functions     5     0    5.3.0   Bartlett\CompatInfo\Reference\closure-335-372
 Internal Functions 47    2    5.2.0   json_encode
 Constants          13    3    5.3.0   __DIR__
 Total                         5.3.0

Let’s explain the results. We have 12 extensions, 4 optionals due to conditional code, with Core that requires at least PHP 5.3.0, and so on for all others components.

Since release 3.3.0 only, if you want to have a full report of all elements without to specify each analyser, just enter the following command :

$ phpcompatinfo analyser:run . --php

Since release 3.4.0, the condition analyser results are also included.

To see details of conditional code (Cond column in summary report), run following command :

$ phpcompatinfo analyser:run . condition

and you should obtain something like this :

Data Source Analysed

Directories                                          7
Files                                              127

Conditional Code Analysis

   Condition                           REF      EXT min/Max PHP min/Max
   class_exists(\PHP_Timer)            user                 4.0.0
   defined(INTL_ICU_VERSION)           intl     2.0.0b1     5.3.7
   defined(OPENSSL_VERSION_NUMBER)     openssl  5.2.0       5.2.0
   defined(OPENSSL_VERSION_TEXT)       openssl  5.2.0       5.2.0
   function_exists(curl_version)       curl     4.0.2       4.0.2
   function_exists(event_priority_set) libevent 0.0.5       5.3.0
   Total [6]                                                5.3.7

Summary

Let’s review what we’ve done :

  • downloaded the latest stable PHAR version.

  • prepared your JSON configuration file that is required to run CompatInfo commands.

  • executed your first parse on the CompatInfo data source.

Next

Choose your way depending of your skill level.

Read more
  • Want to learn more about the command line interpreter (CLI) version, interface that do CompatInfo an easy tool without to write a line of PHP code, have a look on user’s guide

  • 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

  • You are a user of previous version 2.26 that is really different, and want to upgrade to the new major version 3, and keep your old environment still running, have a look on migration’s guide