PHP Classes

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (33)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2021-06-25 (5 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 105 All time: 9,473 This week: 171Up
Version License PHP version Categories
db-draw 1.0.0Custom (specified...5PHP 5, Graphics, Utilities and 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  
Name: jawira <contact>
Classes: 8 packages by
Country: Belgium Belgium
Age: ???
All time rank: 347817 in Belgium Belgium
Week rank: 917 Up5 in Belgium Belgium Up
Innovation award
Innovation award
Nominee: 6x

Details

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

  Files folder image Files  /  docs  
File Role Description
Files folder imageimages (1 file)
  Accessible without login Plain text file dev.md Data Auxiliary data

  Files folder image Files  /  docs  /  images  
File Role Description
  Accessible without login Image file build.png Data Auxiliary data

  Files folder image Files  /  resources  
File Role Description
Files folder imagedc (1 directory)
Files folder imageoutput (6 files)
Files folder imagesql (1 file)

  Files folder image Files  /  resources  /  dc  
File Role Description
Files folder imagephp (2 files)

  Files folder image Files  /  resources  /  dc  /  php  
File Role Description
  Accessible without login Plain text file Dockerfile Data Auxiliary data
  Accessible without login Plain text file zzz-php-settings.ini Data Auxiliary data

  Files folder image Files  /  resources  /  output  
File Role Description
  Accessible without login Image file maxi.png Data Auxiliary data
  Accessible without login Plain text file maxi.puml Data Auxiliary data
  Accessible without login Image file midi.png Data Auxiliary data
  Accessible without login Plain text file midi.puml Data Auxiliary data
  Accessible without login Image file mini.png Data Auxiliary data
  Accessible without login Plain text file mini.puml Data Auxiliary data

  Files folder image Files  /  resources  /  sql  
File Role Description
  Accessible without login Plain text file schema.sql Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageRelational (6 files, 1 directory)
  Plain text file DbDraw.php Class Class source
  Plain text file DbDrawException.php Class Class source
  Plain text file Toolbox.php Class Class source

  Files folder image Files  /  src  /  Relational  
File Role Description
Files folder imageDiagram (4 files)
  Plain text file Column.php Class Class source
  Plain text file ElementInterface.php Class Class source
  Plain text file Entity.php Class Class source
  Plain text file Raw.php Class Class source
  Plain text file Relationship.php Class Class source
  Plain text file Views.php Class Class source

  Files folder image Files  /  src  /  Relational  /  Diagram  
File Role Description
  Plain text file AbstractDiagram.php Class Class source
  Plain text file Maxi.php Class Class source
  Plain text file Midi.php Class Class source
  Plain text file Mini.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file DiagramTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:105
This week:0
All time:9,473
This week:171Up
For more information send a message to info at phpclasses dot org.