Doctrine Relations Analyzer is a tool designed to analyze and visualize cascade relationships within Doctrine ORM entities in Symfony projects. It helps developers understand how deletion operations propagate through related entities and assists in identifying potential issues or optimizations in data management strategies.
Note
Why is it important?
Managing cascade operations, especially deletions, is crucial to avoid unintentional data loss. This tool provides a human-readable summary to help developers review and understand these relationships, ensuring they are intentional and correctly implemented.
Warning
This project is a work in progress. Contributions and feedback are welcome.
- PHP >= 8.1
- Symfony >= 6.4
- Doctrine 2|3
- Graphviz package:
- For Alpine Linux:
graphviz fontconfig ttf-freefont
- For Alpine Linux:
Open a command console, enter your project directory and execute:
composer require --dev huluti/doctrine-relations-analyser
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
composer require --dev huluti/doctrine-relations-analyser
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php
return [
// ...
DoctrineRelationsAnalyserBundle\DoctrineRelationsAnalyserBundle::class => ['dev' => true, 'test' => true],
];
php bin/console doctrine-relations-analyser:analyse
To check deletion relations of two entities in a graph:
php bin/console doctrine-relations-analyser:analyse -o data/ -g --entities="App\\Entity\\User,App\\Entity\\Workspace" -m deletions
- --entities: Optional. Comma-separated list of entities to analyze
- -m, --mode: Optional. Analysis mode (all, deletions) [default: "all"]
- -o, --output: Optional. Output path for reports generated
- -g, --graph: Optional. Generate Graphviz graph
- --graph-format: Optional. Graph image format (png, svg) [default: "png"]
- -V, --version: Optional. Display help for the given command. When no command is given display help for the list command
- -h, --help: Optional. Display this application version
- Only work with first joinColumn for now.
Contributions are welcome! If you have ideas for improvements, new features, or bug fixes, please open an issue or a pull request.
Do you like the tool? Would you like to support its development? Feel free to donate 🤗
This project is licensed under the MIT License.