PHP CompatInfo is a library that can find the minimum version and the extensions required for a piece of code to run.
Running on PHP greater or equal than 7.4 for parsing source code in a format PHP 5.2 to PHP 8.1
- Parse source code in format PHP 5.2 to PHP 8.1
- Detect PHP features for each Major/minor versions
- Detect versions of all directives, constants, functions, classes, interfaces of 100 extensions and more
- Display/Inspect list of extensions, and their versions supported
Parsing PHP 5, PHP 7 or PHP 8 code into an abstract syntax tree (AST) is provided by the PHP-Parser library.
Contextual elements and minimum PHP versions detection provided by following node visitors.
PHP-Parser Node Visitors
- Parent references with the
- Name Resolution with the
- Version Resolution with the
- Data Collector(s) with common
- Data Collector(s) contract with the
- Collector Handler for both Profile and Profiler with
- Profile information for a single data source with
They are grouped by categories to solve PHP features (from 4.0 to 7.4)
- Arrays (2)
- Classes (6)
- Constants (3)
- ControlStructures (2)
- Expressions (3)
- FunctionDeclarations (3)
- Generators (1)
- Keywords (1)
- Numbers (1)
- Operators (4)
- TextProcessing (1)
- UseDeclarations (2)
PHPCompatInfo can be extended by registering objects that implement one or more of the following interfaces:
Furthermore, extensions may implement the
Symfony\Component\EventDispatcher\EventSubscriberInterface in order to have its event handlers automatically registered with the EventDispatcher when the extension is loaded.
Load a config for CLI Application with the
Read How to Load --config With Services in Symfony Console to learn more.
Learn what code is consider as conditional, detected or not (with CompatInfo 5.4)
Sometimes you don't want to scan a certain directory while analysing data source.
Learn how to do from console (CLI) or php script (API).