PHPackages                             pongee/database-schema-visualization - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. pongee/database-schema-visualization

ActiveLibrary[Database &amp; ORM](/categories/database)

pongee/database-schema-visualization
====================================

Database schema visualization

5.1.1(2w ago)46.8k↑12%1[1 PRs](https://github.com/pongee/database-schema-visualization/pulls)MITPHPPHP &gt;=8.5CI passing

Since Jan 5Pushed 2w ago1 watchersCompare

[ Source](https://github.com/pongee/database-schema-visualization)[ Packagist](https://packagist.org/packages/pongee/database-schema-visualization)[ RSS](/packages/pongee-database-schema-visualization/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (4)Dependencies (16)Versions (18)Used By (0)

Database schema visualization
=============================

[](#database-schema-visualization)

[![Latest Stable Version](https://camo.githubusercontent.com/a243c11cf8a8b0fad2bdddf2fda3a12c863302359ccc20ba9eac12f1917c4b80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f6e6765652f64617461626173652d736368656d612d76697375616c697a6174696f6e2e737667)](https://packagist.org/packages/pongee/database-schema-visualization)[![Minimum PHP Version](https://camo.githubusercontent.com/e254d2360ba947036667c1479973c00c113b48a313a5244927fa0247862600f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706f6e6765652f64617461626173652d736368656d612d76697375616c697a6174696f6e)](https://php.net/)

Project goal
------------

[](#project-goal)

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

Supported databases
-------------------

[](#supported-databases)

- MySQL
- MariaDB
- Apache Cassandra (Basics)

Supported Output formats
------------------------

[](#supported-output-formats)

- PNG, SVG image
- Plantuml raw text
- Json
- Markdown

Installation
------------

[](#installation)

```
$ composer require pongee/database-schema-visualization
```

Commands
--------

[](#commands)

Every command reads a schema file and writes the result to **stdout**, so redirect it into a file. Foreign keys are resolved automatically from the schema.

Each command exists for both MySQL (`mysql:`) and Apache Cassandra (`cassandra:`):

CommandOutput`mysql:json` / `cassandra:json`JSON`mysql:plantuml` / `cassandra:plantuml`PlantUML raw text`mysql:markdown` / `cassandra:markdown`Markdown`mysql:image` / `cassandra:image`PNG / SVG imageArgument and options:

NameDescription`file`Path to the schema file. **Required.**`--type`Image format for the `image` commands: `png` (default) or `svg`.`--template`Twig template used for rendering. Defaults to the bundled template.Usage
-----

[](#usage)

The command, argument and options are the same across every run mode below — see [Commands](#commands) for the full list.

### Command line

[](#command-line)

```
$ php ./database-schema-visualization  [options]  > output
```

For example:

```
$ php ./database-schema-visualization mysql:image --type png ./example/schema/sakila.sql > ./example/output/sakila/sakila.png
```

Output: [![Example output](example/output/sakila/sakila.png?raw=true "Output")](example/output/sakila/sakila.png?raw=true)

### Docker

[](#docker)

The image is published to Docker Hub, built for both `linux/amd64` and `linux/arm64`.

```
$ docker pull pongeepublic/database-schema-visualization:latest
```

Mount your schema into the container and pass the same command and options as on the CLI:

```
$ docker run --rm -v "$PWD/schema.sql:/app/schema.sql" \
    pongeepublic/database-schema-visualization mysql:image --type png schema.sql > diagram.png
```

List the available commands:

```
$ docker run --rm pongeepublic/database-schema-visualization list
```

### PHP

[](#php)

#### Png export

[](#png-export)

```
