Architecture
This guide is dedicated to all PHP developers that want to learn more about each component.
As application is following the Domain-driven design (DDD) principle, the directory structure match this one.
src/
├── Application
├── Infrastructure
└── Presentation
Application layer
Analyser(s)
The CompatibilityAnalyser
has the responsibility to collects different metrics to find out the minimum version
and the extensions required for a piece of code to run.
To do so, we mainly use the PhpParser
, DataCollector
and Sniffs
.
Collection(s)
Configuration
The ConfigResolver
component is in charge to handle all arguments/options provided by an instance of Symfony\Component\Console\Input\InputInterface
You will find usage into the Bartlett\CompatInfo\Application\Kernel\ConsoleKernel::createFromInput
function.
Data Collector(s)
This element is in charge to store data (rule id, php and extension versions found) for later produce results by Extension/Reporter
.
Event(s)
CompatInfo
use the Symfony Event-Dispatcher component to avoid tight coupling
between a set of interacting objects.
Bartlett\CompatInfo\Application\Event\Dispatcher\EventDispatcher
is in charge to dispatch all events
to other elements (extensions: logger, progressbar and reporters) of this application.
Extension(s)
Kernel
This element is the main entry point of the bin/phpcompatinfo
command line runner.
Logger
Parser
We use a PHP Parser to parse source code into an abstract syntax tree (AST).
Each Sniffs
(rules) identified by a fingerprint (AST nodes) will then be stored into the DataCollector
.
Polyfill(s)
Profiler
Query(s)
Service(s)
Sniffs
Each one has responsibility to detect a specific PHP feature.
Infrastructure layer
Both layers Application and Presentation talk to each other with two buses (one for Queries, and another one for Commands).
We used the use the Symfony Messenger component to realize these actions.
Presentation layer
The Command Line Runner of CompatInfo
is a Symfony Console Application with many Command.
- all
db:*
commands are inherited directly fromCompatInfoDB
analyser:run
is the main command to parse a datasource and print results of analysisrule:list
is a command to identify each rule found during analysis (id, description, sniff used)