Skip to content

Generating diagrams

DoctrineDiagramBundle provides two Symfony commands to generate diagrams from your database:

  • doctrine:diagram:er - To generate Entity-Relationship diagrams.
  • doctrine:diagram:class - To generate Class diagrams.

Generating Entity-Relationship diagrams

An Entity-Relationship (ER) diagram visually represents the entities (such as tables) in a database, their attributes (such as columns), and the relationships between them.

Use the following command to generate Entity-Relationship diagrams:

bin/console doctrine:diagram:er

You can also use the following shortcut:

bin/console d:d:er

If you are using the default configuration, a file named er.svg will be created at the root of your project.

er diagram

If your application uses multiple databases, you can specify which DBAL connection to use using the --connection option:

bin/console doctrine:diagram:er --connection=employees

You can also set the DBAL connection in doctrine_diagram.yaml. See configuration for the available command options and configuration file settings.

doctrine_diagram:
    er:
        connection: employees

Set connection to null, and the default connection will be used.

Generating Class diagrams

A UML Class diagram visually represents the Doctrine Entities in your project, including their properties, methods, and the relationships between them.

Use the following command to generate Class diagrams:

bin/console doctrine:diagram:class

You can also use the following shortcut:

bin/console d:d:class

Info

DoctrineDiagramBundle will only use Doctrine entities to generate the diagram. Additionally, only properties with the ORM\Column attribute are displayed, other class properties are ignored.

If you are using the default configuration, a file named class.svg will be created at the root of your project.

Class diagram

If your application uses multiple databases, you can specify which Entity Manager to use using the --em option:

bin/console doctrine:diagram:class --em=customers

In doctrine_diagram.yaml:

doctrine_diagram:
    class:
        em: customers

Set em to null, and the default Entity Manager will be used.

How to pipe output

Use php://stdout as the destination file to redirect image to standard output.

For example:

bin/console doctrine:diagram:er --filename="php://stdout" --format=puml | tee diagram.puml