Skip to content


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 ParentContextVisitor
  • Name Resolution with the NameResolverVisitor
  • Version Resolution with the VersionResolverVisitor


  • Data Collector(s) with common DataCollector and specialized VersionDataCollector classes
  • Data Collector(s) contract with the CollectorInterface
  • Collector Handler for both Profile and Profiler with CollectorTrait
  • Profile information for a single data source with Profile


They are grouped by categories to solve PHP features (from 4.0 to 8.1)

  • Arrays (3)
  • Attributes (1)
  • Classes (10)
  • Constants (3)
  • ControlStructures (4)
  • Enumerations (1)
  • Expressions (3)
  • Fibers (1)
  • FunctionDeclarations (7)
  • Generators (1)
  • Keywords (1)
  • Numbers (2)
  • Operators (5)
  • TextProcessing (1)
  • UseDeclarations (2)


PHPCompatInfo can be extended by registering objects that implement one or more of the following interfaces:

  • BeforeAnalysisInterface
  • AfterAnalysisInterface
  • BeforeFileAnalysisInterface
  • AfterFileAnalysisInterface
  • BeforeTraverseAstInterface
  • AfterTraverseAstInterface
  • BeforeProcessNodeInterface
  • AfterProcessNodeInterface
  • BeforeSetupSniffInterface
  • AfterTearDownSniffInterface
  • BeforeProcessSniffInterface
  • AfterProcessSniffInterface

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.


They are identified by services that implements the Bartlett\CompatInfo\Application\Polyfills\PolyfillInterface.


Load a config for CLI Application with the --config option.

Read How to Load --config With Services in Symfony Console to learn more.

Conditional Code

Learn what code is consider as conditional, detected or not (with CompatInfo 5.4)

Exclude folder(s)

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).

Back to top