onurb/doctrine-yuml-bundle

Symfony Bundle to visualize the mapping of your entities with Yuml

Installs: 86 350

Dependents: 0

Suggesters: 5

Security: 0

Stars: 41

Watchers: 2

Forks: 12

Open Issues: 3

Type:symfony-bundle

1.1.6 2019-06-24 21:44 UTC

This package is not auto-updated.

Last update: 2024-11-19 02:56:52 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Build Status License Latest Stable Version Total Downloads Monthly Downloads Daily Downloads

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 Colored Map with note

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 Color list

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")
    */