Git Product home page Git Product logo

doctrine-yuml-bundle's Introduction

doctrine-yuml-bundle

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

doctrine-yuml-bundle's People

Contributors

glynnforrest avatar nono1971 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

doctrine-yuml-bundle's Issues

Output extension

It would be great to have a parameter that let us choose the output extension, like .svg, .png or .jpg.

Thanks again for your work !

"Impossible class count value 0"

I can't generate any file:

$ app/console yuml:mappings
20:35:38 ERROR     [console] Error thrown while running command "yuml:mappings". Message: "Impossible class count value 0" ["exception" => Exception { …},"command" => "yuml:mappings","message" => "Impossible class count value 0"]

In StringGeneratorHelper.php line 104:
                                  
  Impossible class count value 0  
                                  

yuml:mappings [-f|--filename FILENAME] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

Using SF 3.4.

Some stacktrace bits:

StringGeneratorHelper->getCountSide(0)
in vendor/onurb/doctrine-metadata-grapher/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator/StringGeneratorHelper.php (line 67)
StringGeneratorHelper->makeDoubleSidedLinkString('[QsContractorBundle.Entity.ContractorAttachment|isVisible : integer;expirationDate : date]', '[QsContractorBundle.Entity.Signature|firstname : string (255);lastname : string (255);email : string (255);agree : boolean;creationDate : datetime;+id : integer]', false, false, 'Attachments', 0, 'Signature', 1)
in vendor/onurb/doctrine-metadata-grapher/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator.php (line 172)

Exception HTTP/2 stream 0 was not closed cleanly

Got error like this when I try to run the command :
bin/console --env=rc yuml:mappings -f test.svg
14:46:44 ERROR [app] Exception HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1) ["file" => "/Users/.../vendor/onurb/doctrine-yuml-bundle/lib/Onurb/Bundle/YumlBundle/Curl/Curl.php

Symfony4: The profiler template "OnurbYumlBundle:Toolbar:toolbar.html.twig" for data collector "doctrine_yuml" does not exist.

Hi!

I'm trying to run your bundle on my Symfony4 site, even if I know it is not really made for this version.

When loading a page, the web profiler toolbar displays:

An error occurred while loading the web debug toolbar.

Here is the error message:

Uncaught PHP Exception UnexpectedValueException: "The profiler template "OnurbYumlBundle:Toolbar:toolbar.html.twig" for data collector "doctrine_yuml" does not exist." at .../vendor/symfony/web-profiler-bundle/Profiler/TemplateManager.php line 90

So... Is there a way to get it working?

Thank you

Impossible class count value 0

Hi! I installed the bundle but I got the following error:

➜  dockerized git:(develop) ✗ php bin/console yuml:mappings -vv

In StringGeneratorHelper.php line 104:

  [Exception]
  Impossible class count value 0


Exception trace:
 Onurb\Doctrine\ORMMetadataGrapher\YumlMetadataGrapher\StringGenerator\StringGeneratorHelper->getCountSide() at /var/www/idinary-dockerized/vendor/onurb/doctrine-metadata-grapher/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator/StringGeneratorHelper.php:67
 Onurb\Doctrine\ORMMetadataGrapher\YumlMetadataGrapher\StringGenerator\StringGeneratorHelper->makeDoubleSidedLinkString() at /var/www/idinary-dockerized/vendor/onurb/doctrine-metadata-grapher/lib/Onurb/Doctrine/ORMMetadataGrapher/YumlMetadataGrapher/StringGenerator.php:172
 Onurb\Doctrine\ORMMetadataGrapher\YumlMetadataGrapher\StringGenerator->getAssociationString() at /var/www/idinary-dockerized/vendor/onurb/doctrine-metadata-grapher/lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php:176
 Onurb\Doctrine\ORMMetadataGrapher\YUMLMetadataGrapher->writeAssociation() at /var/www/idinary-dockerized/vendor/onurb/doctrine-metadata-grapher/lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php:163
 Onurb\Doctrine\ORMMetadataGrapher\YUMLMetadataGrapher->writeClassAssociations() at /var/www/idinary-dockerized/vendor/onurb/doctrine-metadata-grapher/lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php:125
 Onurb\Doctrine\ORMMetadataGrapher\YUMLMetadataGrapher->dispatchStringWriter() at /var/www/idinary-dockerized/vendor/onurb/doctrine-metadata-grapher/lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php:99
 Onurb\Doctrine\ORMMetadataGrapher\YUMLMetadataGrapher->generateFromMetadata() at /var/www/idinary-dockerized/vendor/onurb/doctrine-yuml-bundle/lib/Onurb/Bundle/YumlBundle/Yuml/YumlClient.php:65
 Onurb\Bundle\YumlBundle\Yuml\YumlClient->makeDslText() at /var/www/idinary-dockerized/vendor/onurb/doctrine-yuml-bundle/lib/Onurb/Bundle/YumlBundle/Command/YumlCommand.php:46
 Onurb\Bundle\YumlBundle\Command\YumlCommand->execute() at /var/www/idinary-dockerized/vendor/symfony/console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at /var/www/idinary-dockerized/vendor/symfony/console/Application.php:883
 Symfony\Component\Console\Application->doRunCommand() at /var/www/idinary-dockerized/vendor/symfony/framework-bundle/Console/Application.php:86
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/idinary-dockerized/vendor/symfony/console/Application.php:241
 Symfony\Component\Console\Application->doRun() at /var/www/idinary-dockerized/vendor/symfony/framework-bundle/Console/Application.php:74
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/idinary-dockerized/vendor/symfony/console/Application.php:143
 Symfony\Component\Console\Application->run() at /var/www/idinary-dockerized/bin/console:39

My system information

------------------------------- -------------------------------------------------------------------------------
  Symfony
 ------------------------------- -------------------------------------------------------------------------------
  Version                         4.0.9
  End of maintenance              07/2018
  End of life                     01/2019
 ------------------------------- -------------------------------------------------------------------------------
  Kernel
 ------------------------------- -------------------------------------------------------------------------------
  Type                            App\Kernel
  Name                            src
  Environment                     dev
  Debug                           true
  Charset                         UTF-8
  Root directory                  ./src
  Cache directory                 ./var/cache/dev (17.6 MiB)
  Log directory                   ./var/log (8.2 MiB)
 ------------------------------- -------------------------------------------------------------------------------
  PHP
 ------------------------------- -------------------------------------------------------------------------------
  Version                         7.2.5
  Architecture                    64 bits
  Intl locale                     en_US_POSIX
  Timezone                        UTC (2018-05-14T00:52:10+00:00)
  OPcache                         false
  APCu                            true
  Xdebug                          true

config/packages/dev/yum.yaml

parameters:
    onurb_yuml.extension: png
    onurb_yuml.style: scruffy
    onurb_yuml.direction: LR
    onurb_yuml.scale: small

config/routes/dev/yuml.yaml

doctrine_yuml:
    resource: "@OnurbYumlBundle/Resources/config/routing.yml"
    prefix:   /

Any idea?

Symfony 5 support

I notice that the master branch has modified the composer.json, but that is not a new release on packagist.

Doctrine/Common 3 compatability

doctrine/common is now 3.0+ which conflicts with the current master branch composer.json of this bundle.

Not sure if any code changes are needed or if it's just a dependency change, I was hoping to try this bundle on a project but it's already using doctrine/common 3.1.0 so can't install this bundle.

Bundle uploads visualization of entities without any notice to yuml.me

This bundle uploads the visualization of your entities within the project to yuml.me and provides a public url. I did not find any possibility to delete the image from public access. This should be prominent in the documentation and should be optional. Rather than upload this (critical) information I would prefer to be asked before the data is processed

Routes generated automatically

It could be great if routes were generated automatically in

config/routes/dev/yuml.yaml

For new symfony projects, don't you think ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.