prooph / message-flow-analyzer
Static code analyzer for prooph projects
Installs: 2 947
Dependents: 0
Suggesters: 0
Security: 0
Stars: 30
Watchers: 8
Forks: 4
Open Issues: 7
Requires
- nikic/php-parser: ^3.1
- roave/better-reflection: ^2.0
- symfony/console: ^3.3 || ^4.0
Requires (Dev)
- malukenho/docheader: ^0.1.4
- phpunit/phpunit: ^6.0
- prooph/bookdown-template: ^0.2.3
- prooph/common: ^4.1
- prooph/event-sourcing: ^5.2
- prooph/php-cs-fixer-config: ^0.1.1
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2024-12-05 14:39:54 UTC
README
A static code analyzer to extract message flow of a prooph project
Installation
composer require --dev prooph/message-flow-analyzer
Configuration
The analyzer can be configured using a json file. By default the analyzer uses a prooph_analyzer.json
located in the current working directory.
An example of a default config can be found in the test example project
Run
php vendor/bin/prooph-analyzer project:analyze
Why?
The prooph message flow analyzer scans your project for prooph messages and collects information how these messages flow through your project source code :)
The analysis contains information about:
- commands, events, queries
- message handlers per message (command handler, event listner, process manager, ...)
- message producers per message (controller, cli commands, process manager, ...)
- event recorders per event (classes implementing prooph's AggregateRoot or using the EventProducerTrait)
The message flow is written to an output file (prooph_message_flow.json
by default).
For now that's it. But imagine what you can do with this information! We'll add different output formatters to generate config for d3js or draw.io.
The message flow analyzer will also be part of the upcoming event-store-mgmt-ui
and will allow you to connect the message flow with your event streams
for debugging and monitoring.
How?
The package uses the excellent libraries roave/better-reflection and nikic/php-parser (which is used by Roave/BetterReflection internally, too)
WIP
prooph/message-flow-analyzer
and the event-store-mgmt-ui
are work in progress. There is no roadmap defined yet. If you think your project could benefit
from a stable version and you or your company would like to support development then get in touch.
Filters
You can add include and exclude filters for files and directories. prooph/message-flow-analyzer
ships with some default filters.
Check the linked example config above. The filter implementations can be found in the Filter dir
ClassVisitors
Class visitors are called for every php class found in the project and not excluded by a filter.
They take a Roave\BetterReflection\Reflection\ReflectionClass
and the Prooph\MessageFlowAnalyzer\MessageFlow
as input and if a visitor finds something
interesting in the class it can add this information to the MessageFlow
.
Again prooph/message-flow-analyzer
ships with default class visitors (see example config) which can be found in the Visitor dir.
Run it against proophessor-do
You can see prooph/message-flow-analyzer
in action by running it against proophessor-do.
- Clone proophessor-do
- Add
prooph/message-flow-analyzer: dev-master
to therequire-dev
config of proophessor-do'scomposer.json
- Run composer install
- Copy prooph_analyzer.json into root dir of proophessor-do
- Copy ExcludeBlacklistedFiles.php into
src/Infrastructure/ProophAnalyzer
. This is needed because proophessor-do contains a prepared factory for mongodb connection but mongo is not installed by default so the mongo classes cannot be loaded. - Add
"Prooph\\ProophessorDo\\Infrastructure\\ProophAnalyzer\\ExcludeBlacklistedFiles"
as last entry in theprooph_analyzer.json
fileInfoFilters
array. - Run
php vendor/bin/prooph-analyzer project:analyze
and watch the generated output fileprooph_message_flow.json
If this is too much work right now and you only want to see the result: prooph_message_flow.json