onurb / doctrine-yuml-bundle
Symfony Bundle to visualize the mapping of your entities with Yuml
Installs: 85 922
Dependents: 0
Suggesters: 5
Security: 0
Stars: 41
Watchers: 2
Forks: 12
Open Issues: 3
Type:symfony-bundle
Requires
- php: >=7.1.3
- doctrine/annotations: 1.*
- doctrine/common: ~2.0
- doctrine/orm: ~2.0
- onurb/doctrine-metadata-grapher: ~1.0
- symfony/config: ~4.2
- symfony/console: ~3.0|~4.0
- symfony/dependency-injection: ~3.0|~4.0
- symfony/framework-bundle: ~3.0|~4.0
- symfony/http-foundation: ~3.0|~4.0
- symfony/http-kernel: ~3.0|~4.0
- symfony/profiler-pack: ~1.0
- symfony/routing: ~3.0|~4.0
Requires (Dev)
- php: >=7.0
- doctrine/doctrine-bundle: ^1.5
- phpunit/phpunit: ~6.5
- squizlabs/php_codesniffer: ~2
README
Bundle to visualise doctrine entities graph with yuml in Symfony4
This bundle is based on Marco Pivetta's work for zend doctrine ORM Module and zend developper tools
It uses the yuml.me api to display your project's objects mapping.
Installation
Symfony 4
Run the composer require onurb/doctrine-yuml-bundle
command in your console
Adjust your parameters to personalize the render in config/packages/dev/yuml.yaml, or use annotations as describe bellow
Adjust the route (if you want to add a prefix) in config/routes/dev/yuml.yaml
Symfony 3
symfony 3 is not supported since 1.1.6, if you didn't migrate to SF4 yet, use version 1.1.5
- Add this bundle to your project as a composer dependency:
// composer.json { // ... require: { // ... "onurb/doctrine-yuml-bundle": "1.1.5" } }
- Declare the bundle in your application kernel:
// app/AppKernel.php public function registerBundles() { // ... if (in_array($this->getEnvironment(), array('dev', 'test'))) { // ... $bundles[] = new Onurb\Bundle\YumlBundle\OnurbYumlBundle(); } return $bundles; }
- Add this route in your global routing_dev configuration (with optional prefix)
# app/config/routing_dev.yml # ... doctrine_yuml: resource: "@OnurbYumlBundle/Resources/config/routing.yml" prefix: /my_prefix/
configure access to the yuml route (if you use security of course)
Use
Click on Doctrine icon added in the dev toolbar.
Run the yuml:mappings
console command to save the image locally.
Personalize the render
Full personalisation for mapping rendering, defining parameters or using Metadatagrapher annotations
define the output file extension
Use the parameter file :
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.extension: svg # ...
Extensions allowed : jpg, png (default), svg, pdf, or json
define the yuml rendering style
Use the parameter file :
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.style: scruffy # ...
Styles allowed : plain (default), boring or scruffy
define the graph direction
Use the parameter file :
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.direction: LR # ...
Directions allowed : LR (left to Right), RL (Right to Left), TB (Top to bottom => default).
define the graph scale
Use the parameter file :
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.scale: huge # ...
Scales allowed : huge, big, normal (default), small or tiny.
Hide entities attributes properties (unique, type, length, ...)
Use the parameter file :
# app/config/parameters.yml => symfony 3 # config/packages/dev/yuml.yaml => symfony 4 parameters: onurb_yuml.show_fields_description: false # ...
this parameter is set to true by default since v1.1
Warning : In Symfony 3, don't forget to also define parameter keys in parameters.yml.dist to avoid symfony update
to clear your parameters
Toggle attributes properties on a specific class using annotations
to show only desired classes details if global parameter is set to false :
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; /** * @Grapher\ShowAttributesProperties() */ Class MyClass { // ... }
And, if set to true (default), you can hide properties for a specific class :
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; /** * @Grapher\HideAttributesProperties() */ Class MyClass { // ... }
Define colors for entities rendering
Define default color for a complete bundle or namespace by defining it in parameters.yml
# app/config/parameters.yml => Symfony 3 # config/packages/dev/yuml.yaml => Symfony 4 parameters: onurb_yuml.colors: App\Security: red App\Blog: blue # ...
You can also define colors for classes this way... but it is easier using annotations as described next
Complete list of yuml colors availables here
Define Entity color in graph using annotations
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; /** * @Grapher\Color("blue") */ Class MyClass { }
Display specific entity method
You can display specific methods in the graph, using annotations
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; // ... Class MyEntity { // ... /** * @Grapher\IsDisplayedMethod() */ public function myDisplayedMethod() { // ... } }
Hide columns
Hide all columns of the entity
If you want, you can hide Entity attributes with annotations : using annotation on the class :
/** * @Grapher\Hidecolumns */ MyEntity { //[...] }
Hide specific column
Or hide a specific secret column you want to hide, using annotation on the Entity column : (it could be usefull to hide you credential logic, or to avoid the display recurrent fields, like created_at, or updated_at in the graph...)
MyEntity { /** * @ORM\Column(/* ... */) * @Grapher\HiddenColumn */ private $secret; }
Add notes to comment entities in the graph
use annotations :
namespace My\Bundle\Entity use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher; /** * @Grapher\Note("Some information about this class") */ Class MyClass { }
Notes are yellow by default, but you can customize note's' color
/** * @Grapher\Note(value="Some information about this class", color="blue") */