CompatInfo always needs a file in JSON format to run. It should be found either in the current, $HOME/.config/, or /etc directory.

By setting the COMPATINFO environment variable it is possible to set the filename of phpcompatinfo.json to something else.

E.g: COMPATINFO=my-phpcompatinfo.json

The minimalist JSON file phpcompatinfo.json is :

{
    "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": "Structure",
            "class": "Bartlett\\Reflect\\Analyser\\StructureAnalyser"
        }
    ]
}
source-providers
this entry provide list of your data sources to parse.
plugins
this entry list all plugins added to the core base code of PHP CompatInfo.
analysers
this entry list all analysers that may be used with the analyser:run command.

Source Providers

There are lot of way to filter your data source. Each rule follow the syntax of Symfony Finder Component.

The Location is the only mandatory criteria. It tells the Finder which directory to use for the search.

In a simple directory
    {
        "in": ". as current"
    }
If you want to identify a data source easily by a short name, the alias (right of as) is compared with the --alias option constraint.
Search in several locations
    {
        "in": ". as current",
        "in": "src/"
    }
Use wildcard characters to search in the directories matching a pattern:
    {
        "in": "src/Bartlett/R*"
    }
Search directly in archives (phar, zip, tar) with the phar:// protocol
    {
        "in": "phar://path/to/archive.zip"
    }
Restrict files by name and/or extension.
    {
        "in": "phar://path/to/archive.zip",
        "name": "*.php"
    }
Restrict files by size.
    {
        "in": "phar://path/to/archive.zip",
        "name": "*.php",
        "size": "< 10K"
    }
Restrict files by last modified dates.
    {
        "in": ". as current",
        "date": "since yesterday"
    }

By default, the Finder recursively traverse directories.

Restrict the depth of traversing.
    {
        "in": ". as current",
        "depth": "< 3"
    }

Plugins

There are a number of optional plugins you can use along with CompatInfo to add more capabilities.

The Analyser is the only mandatory plugin you should add to parse your data source.

In your phpcompatinfo.json configuration file, add in plugins section the following entry:

    {
        "name": "Analyser",
        "class": "Bartlett\\Reflect\\Plugin\\Analyser\\AnalyserPlugin"
    }
The Analyser plugin is a component from Reflect, and not from CompatInfo. Take care of namespace !

The name key identify the namespace of optional commands the plugin may provide.

Each name key must be unique to avoid conflicts.

The class key identify the name of the class that implement the plugin features.

Analysers

There are a number of optional analysers you can use along with the Reflect Analyser Plugin.

The Summary is the default analyser you should add to obtain results when you parse your data source.

In your phpcompatinfo.json configuration file, add in analysers section the following entry:

    {
        "name": "Structure",
        "class": "Bartlett\\CompatInfo\\Analyser\\SummaryAnalyser"
    }

The name key identify the name you can optionally invoke with the analyser:run command.

The two following commands do the same:

Used implicitly the summary analyser (default behavior)
$ phpcompatinfo analyser:run .
Named explicitly the summary analyser
$ phpcompatinfo analyser:run . summary
Each name key must be unique to avoid conflicts.

The class key identify the name of the class that implement the analyser features.

Read more

For developers who want to extend or change CompatInfo features.

  • Want to create a new plugin, have a look on developer’s guide in the Plugins section.

  • Want to create a new analyser, have a look on developer’s guide in the Analysers section.