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.3.0.phar
$ mv phpcompatinfo-3.3.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.3.0.phar
$ php phpcompatinfo-3.3.0.phar --version

With both methods then you have this output :

phpCompatInfo version 3.3.0 build ...
represents the Git commit hash of this version

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"
        }
    ]
}

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                                              124

Global Analysis

                    Count PHP min Elements highlight
 Extensions         11    5.3.7   intl
 Namespaces         8     5.3.7   Bartlett\CompatInfo\Reference
 Interfaces         3     5.3.0   Bartlett\CompatInfo\Reference\ReferenceInterface
 Traits             0
 Classes            134   5.3.0   Bartlett\CompatInfo\Reference\Extension\RecodeExtension
 User Functions     5     5.3.0   Bartlett\CompatInfo\Reference\closure-288-322
 Internal Functions 49    5.2.0   json_decode
 Constants          11    5.3.7   INTL_ICU_VERSION
 Total                    5.3.7

Let’s explain the results. We have 11 extensions with intl that requires at least PHP 5.3.7, 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

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