PHP Classes

DB Draw PHP UML Diagram Generator: Create a database Entity-Relationship UML diagram

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 118 All time: 9,534 This week: 455Up
Version License PHP version Categories
db-draw 1.0.0Custom (specified...5PHP 5, Graphics, Tools
Description 

Author

This package can create a database Entity-Relationship UML diagram.

It can take as parameter a connection object previously set to connect to a given database.

The package can analyse the database table structure and create a diagram based on the relationship of the tables and returns en entity-relationship diagram definition in UML format.

It can also take the UML diagram and render it as an image in UML format.

Innovation Award
PHP Programming Innovation award nominee
June 2021
Number 3
UML is a specification for describing different aspects of a software project to help to document how the project should work.

One of those aspects is how the different types of objects manipulated in a software project are related to each other.

An entity-relationship diagram is meant to describe how entity objects are stored in a relational database.

This package can automatically create a UML entity-relationship diagram by connecting to a given database server and extracting the database structure of tables and their relations.

This allows developers to create documentation from an existing project database based on the standard for UML entity-relationship diagrams.

Manuel Lemos
Picture of jawira
  Performance   Level  
Innovation award
Innovation award
Nominee: 9x

Winner: 2x

 

Documentation

? 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.

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

mini-diagram

midi-diagram

maxi-diagram

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>


  Files folder image Files (33)  
File Role Description
Files folder imagedocs (1 file, 1 directory)
Files folder imageresources (3 directories)
Files folder imagesrc (3 files, 1 directory)
Files folder imagetests (1 file)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .php-cs-fixer.dist.php Example Example script
Accessible without login Plain text file build.xml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file docker-compose.yaml Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:118
This week:0
All time:9,534
This week:455Up