? DB Draw
Generate an ER diagram from your existing database.
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:
-
Your application must provide a valid doctrine/dbal connection.
-
Instantiate `\Jawira\DbDraw\DbDraw` using your _dbal connection_.
-
Choose your diagram size (`mini`, `midi`, `maxi`) and call `DbDraw::generatePuml`.
-
Then `DbDraw::generatePuml` will return a PlantUML diagram.
-
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.
Example:
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@127.0.0.1/db-draw',
'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
Installing
composer require jawira/db-draw
Contributing
If you liked this project, ? star it on GitHub.
License
This library is licensed under the MIT license.
*
Packages from jawira
<dl>
<dt>
<a href="https://packagist.org/packages/jawira/plantuml-client"> jawira/plantuml-client
<img alt="GitHub stars" src="https://badgen.net/github/stars/jawira/plantuml-client?icon=github"/></a>
</dt>
<dd>Convert PlantUML diagrams into images.</dd>
<dt>
<a href="https://packagist.org/packages/jawira/plantuml-encoding"> jawira/plantuml-encoding
<img alt="GitHub stars" src="https://badgen.net/github/stars/jawira/plantuml-encoding?icon=github"/></a>
</dt>
<dd>PlantUML encoding functions.</dd>
<dt>
<a href="https://packagist.org/packages/jawira/plantuml">jawira/plantuml
<img alt="GitHub stars" src="https://badgen.net/github/stars/jawira/plantuml?icon=github"/></a>
</dt>
<dd>Provides PlantUML executable and plantuml.jar</dd>
<dt><a href="https://packagist.org/packages/jawira/">more...</a></dt>
</dl>