An open API service indexing awesome lists of open source software.

https://github.com/pongee/database-schema-visualization


https://github.com/pongee/database-schema-visualization

database mariadb mysql plantuml visualization

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

# Database schema visualization

[![Latest Stable Version](https://img.shields.io/packagist/v/pongee/database-schema-visualization.svg)](https://packagist.org/packages/pongee/database-schema-visualization)
[![Minimum PHP Version](https://img.shields.io/packagist/php-v/pongee/database-schema-visualization)](https://php.net/)
[![License](https://img.shields.io/github/license/pongee/database-schema-visualization)](https://github.com/pongee/database-schema-visualization/blob/main/LICENSE)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/pongee/database-schema-visualization)

## Project goal
The aim of this project is to generate database documentation from sql schema.

## Supported databases
- MySQL
- MariaDB
- Apache Cassandra (Basics)

## Supported Output formats
- PNG, SVG image
- Plantuml raw text
- Json

## Pre Installation
- https://graphviz.gitlab.io/download/

## Installation

```bash
$ composer require pongee/database-schema-visualization
or add it the your composer.json and make a composer update pongee/database-schema-visualization.
```
## Usage
### In console
#### PNG export
```bash
$ php ./database-schema-visualization mysql:image ./example/schema/sakila.sql > ./example/img/sakila.png
$ php ./database-schema-visualization mysql:image --type png ./example/schema/sakila.sql > ./example/img/sakila.png
```
Output:
![Example output](example/img/sakila.png?raw=true "Output")

#### SVG export
```bash
$ php ./database-schema-visualization mysql:image --type svg ./example/schema/sakila.sql > ./example/img/sakila.svg
```

#### Json export
```bash
$ php ./database-schema-visualization mysql:json ./example/schema/sakila.sql
```
#### Plantuml export
```bash
$ php ./database-schema-visualization mysql:plantuml ./example/schema/sakila.sql
```

### PHP
#### Png export

```php
run($sqlSchema, $forcedConnectionCollection);

print $imageGenerator->generate($plantumlExport->export($schema));
```
#### Json export
```php
run($sqlSchema, $forcedConnectionCollection);

print $jsonExport->export($schema);
```

This will generate:



{
"tables": {
"foo": {
"columns": [
{
"name": "id",
"type": "INT",
"typeParameters": [
"10"
],
"otherParameters": "UNSIGNED NOT NULL",
"comment": "The id"
}
],
"indexs": {
"simple": [],
"spatial": [],
"fulltext": [],
"unique": []
},
"primaryKey": []
}
},
"connections": []
}