PHP Classes


Recommend this page to a friend!
  Classes of jawira   DB Draw PHP UML Diagram Generator   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: DB Draw PHP UML Diagram Generator
Create a database Entity-Relationship UML diagram
Author: By
Last change:
Date: 1 year ago
Size: 3,480 bytes


Class file image Download

? DB Draw

Generate an ER diagram from your existing database.

Latest Stable Version .gitattributes composer.lock License

How to use

Because DB Draw is a library, you have to use it as a dependency and instantiate it in your project.

In order to create a diagram you have to follow these steps:

  1. Your application must provide a valid doctrine/dbal connection.
  2. Instantiate `\Jawira\DbDraw\DbDraw` using your _dbal connection_.
  3. Choose your diagram size (`mini`, `midi`, `maxi`) and call `DbDraw::generatePuml`.
  4. Then `DbDraw::generatePuml` will return a PlantUML diagram.
  5. Is up to you to convert the _puml_ diagram to another image format (e.g. _png_ or _svg_). I suggest to use jawira/plantuml-client.


use Doctrine\DBAL\DriverManager;
use Jawira\DbDraw\DbDraw;
use Jawira\PlantUmlClient\{Client, Format};

// a. Some logic to retrieve $connection (\Doctrine\DBAL\Connection)
$connectionParams = ['url'    => 'mysql://admin:pass1234@',
                     'driver' => 'pdo_mysql'];
$connection = DriverManager::getConnection($connectionParams);

// b. Generating PlantUML diagram
$dbDiagram = new DbDraw($connection);
$puml      = $dbDiagram->generatePuml(DbDraw::MIDI);
file_put_contents('database.puml', $puml);

// c. Converting & saving png image
$client = new Client();
$png    = $client->generateImage($puml, Format::PNG);
file_put_contents('database.png', $png);

Diagram sizes

$dbDraw = new DbDraw($connection);
$mini   = $dbDraw->generatePuml(DbDraw::MINI); // only table names
$midi   = $dbDraw->generatePuml(DbDraw::MIDI); // like mini with columns
$maxi   = $dbDraw->generatePuml(DbDraw::MAXI); // like midi with views





composer require jawira/db-draw


If you liked this project, ? star it on GitHub.


This library is licensed under the MIT license.


Packages from jawira



<a href=""> jawira/plantuml-client
<img alt="GitHub stars" src=""/></a>

</dt> <dd>Convert PlantUML diagrams into images.</dd>


<a href=""> jawira/plantuml-encoding
<img alt="GitHub stars" src=""/></a>

</dt> <dd>PlantUML encoding functions.</dd>


<a href="">jawira/plantuml
<img alt="GitHub stars" src=""/></a>

</dt> <dd>Provides PlantUML executable and plantuml.jar</dd>

<dt><a href="">more...</a></dt> </dl>