micoli / symfony-cartography
Symfony cartography bundle
v1.0.0
2017-02-07 18:30 UTC
Requires
- php: >=5.5.9
- ext-pdo_sqlite: *
- doctrine/doctrine-bundle: ^1.6
- doctrine/doctrine-cache-bundle: ^1.2
- doctrine/doctrine-fixtures-bundle: ^2.2
- doctrine/orm: ^2.5
- erusev/parsedown: ^1.5
- ezyang/htmlpurifier: ^4.7
- incenteev/composer-parameter-handler: ^2.0
- sensio/distribution-bundle: ^5.0
- sensio/framework-extra-bundle: ^3.0.2
- symfony/monolog-bundle: ^3.0
- symfony/polyfill-apcu: ^1.0
- symfony/swiftmailer-bundle: ^2.3
- symfony/symfony: ^3.2
- twig/extensions: ^1.3
- twig/twig: ^1.28
- white-october/pagerfanta-bundle: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^4.8 || ^5.0
- sensio/generator-bundle: ^3.0
- symfony/phpunit-bridge: ^3.0
This package is auto-updated.
Last update: 2024-10-24 19:31:28 UTC
README
The aim of this bundle is to:
- provide an analysis of your project code bases (classes, class categorization, method calls to other service/class)
- draw a map of all possible method calls from and to a specific class::method. be ware that this map is calculated through static analysis, it's not the classes:methods called during a specific execution, it's all the possible calls from and to a class:method
Requirements
- PHP 8.1.0 or higher;
- PDO-SQLite PHP extension enabled for development;
Installation
composer require --dev micoli/symfony-cartography
- add the line in
config\bundles.php
Micoli\SymfonyCartography\SymfonyCartographyBundle::class => ['dev' => true, 'test' => true],`
- add a route in
config/routes.yaml
when@dev:
_symfony_cartography:
resource: '@SymfonyCartographyBundle/Resources/config/routes.yaml'
prefix: /_cartography
- and create
config/packages/symfony_cartography.yaml
symfony_cartography:
enabled: true
sources:
- '%kernel.project_dir%/src'
filters:
classes:
rules:
- '+App\' # all classes in namespace 'App\' will be excluding
- '-App\Domain\DataFixtures' # except those starting by 'App\Domain\DataFixtures'
method_calls:
exclude_loopback: true #display sameClasse to sameClasse arrows
rules:
- '-Twig\' # do not display call towards classes in 'twig' namespace
- '-ReflectionFunctionAbstract'
- '-Doctrine\'
- '-Symfony\'
- '-Webmozart\'
- '-Psr\'
messenger_dispatchers: # Class/Method used to wire event trough messenger buses
- class: App\Infrastructure\Bus\MessengerCommandBus
method: dispatch
- class: App\Infrastructure\Bus\MessengerEventDispatcher
method: dispatch
graph:
engine: visjs # visjs|plantuml|cytoscape
engine_uri: https://kroki.io/plantuml/svg
# engine_uri: http://127.0.0.1:8080/svg # if local plantuml server
withMethodDisplay: false # display methods in classes
withMethodArrows: false # if disabled, only one arrow from a class to another is draw
leftToRightDirection: false # if disabled graph is drawn top to bottom, else it is draw left To Right
colors: # colors used in graph
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::undefined
color: '#033270'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::doctrineEntity
color: '#1368aa'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::controller
color: '#4091c9'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::messengerCommandHandler
color: '#9dcee2'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::messengerEventListener
color: '#fedfd4'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::messengerEvent
color: '#f29479'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::messengerCommand
color: '#f26a4f'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::symfonyConsoleCommand
color: '#ef3c2d'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::symfonyEventListener
color: '#cb1b16'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::doctrineRepository
color: '#65010c'
- class: !php/enum Micoli\SymfonyCartography\Service\Categorizer\ClassCategory::symfonyEvent
color: '#f29479'
Usage
-
in
webProfiler
toolbar you can see a preview of the call graph from the current controller -
in
webProfiler
page a new section calledcartography
is present -
To clear inner psalm cache and refresh analysedCodebase
bin/console code:cartography --force
Analysing
enrichedClasses: 56
methods: 25
method calls: 73
interfaceImplements: 34
classInterfaces: 35
Analyse done
-
To use a local instance of plantuml
docker run -d -p 8080:8080 plantuml/plantuml-server:jetty
and inconfig/packages/symfony_cartography.yaml
setsymfony_cartography: graph: engine: plantuml engine_uri: http://127.0.0.1:8080/svg
-
else to use a public instance of kroki
symfony_cartography: graph: engine: plantuml engine_uri: https://kroki.io/plantuml/svg
-
Tests
Execute this command to run tests:
$ make tests-all
Todo
- manage symfony events and handler
- manage symfony services
- indirect from interfaces or use service definitions
- get called tree and calling tree