Developed with love by KnpLabs Hire us for your project!
42

doctrine-yuml-bundle

by Nono1971

Bundle to visualise doctrine mapping with yuml in Symfony3

doctrine-yuml-bundle

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

Bundle to visualise doctrine entities graph with yuml in Symfony

Compatible with SF4 or SF3

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

  • Add this bundle to your project as a composer dependency:
    javascript
    // composer.json
    {
    // ...
    require: {
    // ...
    "onurb/doctrine-yuml-bundle": "~1.0"
    }
    }

  • Declare the bundle in your application kernel:
    ```php
    // 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)
    ```yml

    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 :
```yml
# 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 :
```yml
     # 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 :
```yml
# 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 :
```yml
     # 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 :
```yml
# 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 :
```php
    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 :
```php
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
```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
```php
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 :

```php
/**
* @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 :
```php
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
```php
    /**
    * @Grapher\Note(value="Some information about this class", color="blue")
    */
  • update dependencies
    By Nono1971, 1 year ago
  • add yuml.me customization - fixes #6
    By Nono1971, 1 year ago
  • add YumlCommandTest
    By Nono1971, 1 year ago
  • reintroduce yuml:mappings console command
    By Nono1971, 1 year ago
  • datacollector template fix - fixes #4
    By Nono1971, 1 year ago
  • SF4 compatibility - fixes #4
    By Nono1971, 1 year ago
  • Merge pull request #3 from ahazebroucq/master
    By web-flow, 1 year ago
  • Added reset() method to DataCollector
    By web-flow, 1 year ago
  • fix PSR2
    By Nono1971, 1 year ago
  • Integration of metadataGrapher new features
    By Nono1971, 2 years ago
  • v 1.0.3
    By Nono1971, 2 years ago
  • fix travis
    By Nono1971, 2 years ago
  • fix yuml url
    By Nono1971, 2 years ago
  • change readme
    By Nono1971, 2 years ago
  • implements unit tests
    By Nono1971, 2 years ago
  • change library namespace
    By Nono1971, 2 years ago
  • Externalize MetadataGrapher to a library
    By Nono1971, 2 years ago
  • change readme
    By Nono1971, 3 years ago
  • fix service.yml for symfony 3
    By Nono1971, 3 years ago
  • Merge pull request #1 from glynnforrest/cli-command
    By Nono1971, 3 years ago
  • Move download logic to YumlClient and Curl
    By glynnforrest, 3 years ago
  • Add console usage to README
    By glynnforrest, 3 years ago
  • Add console command to create and save yuml image
    By glynnforrest, 3 years ago
  • Extracting logic from controller to a service
    By glynnforrest, 3 years ago
  • minor refactor
    By Nono1971, 3 years ago
  • fix MetadataGrapher - phantom bidirectional relations
    By Nono1971, 3 years ago
  • clean code
    By Nono1971, 3 years ago
  • refactor - extract curl calls in Curl class
    By Nono1971, 3 years ago
  • use curl instead of buzzBundle to avoid dependency
    By Nono1971, 3 years ago
  • refactor controller
    By Nono1971, 3 years ago