PHPackages                             molay76/laravel-mysql2plantuml - 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. molay76/laravel-mysql2plantuml

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

molay76/laravel-mysql2plantuml
==============================

convert mysql schema to plantuml

1.9.2(2y ago)22.7k↓50%MITPHPPHP &gt;=7.2|&gt;=8.0

Since Dec 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/cpt-sugiura/laravel-mysql2plantuml)[ Packagist](https://packagist.org/packages/molay76/laravel-mysql2plantuml)[ RSS](/packages/molay76-laravel-mysql2plantuml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (18)Used By (0)

既存のMySQL製データベースを元にPlantUML製ER図を出力
=================================

[](#既存のmysql製データベースを元にplantuml製er図を出力)

TL;DR
-----

[](#tldr)

```
php artisan dump:mysql2puml

```

/storage/ER以下にPlantUML製ER図が出力されます。

config
------

[](#config)

```
php artisan vendor:publish --provider=Mysql2PlantUml\Mysql2PlantUmlServiceProvider

```

設定ファイルが/config/以下にダンプされます。

以下の例では `Mysql2PlantUml\app\Models\ValueObjects\Relation` クラスのクラス定数を使っています。 `composer require --dev` でこのライブラリをインストールした場合、本番環境では存在しないクラスの参照でエラーが起きます。`require --dev`する場合、クラス定数内で定義されてある文字列を直に設定ファイルに書き込んでください。

### dist\_dir

[](#dist_dir)

出力先のディレクトリを指定します。

```
'dist_dir' => 'storage/ER',

```

### connection

[](#connection)

information\_schemaを指すようにデータベース接続先を指定します。

```
    'connection' => [
        'driver' => 'mysql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE_INFORMATION_SCHEMA', 'information_schema'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'prefix_indexes' => true,
        'strict' => true,
        'engine' => null,
        'options' => extension_loaded('pdo_mysql') ? array_filter(
            [
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]
        ) : [],
    ],

```

### target\_database

[](#target_database)

ER図に表現する対象のデータベース名を指定します。

```
'target_database' => env('DB_DATABASE'),

```

### without\_tables

[](#without_tables)

```
/*
 * ER図上に描かないテーブルを指定します
 */
'without_tables'  => [
    'migrations'
],

```

### relation\_type

[](#relation_type)

多重度の表現方法を指定します。

```
'target_database' => Relation::FORMAT_NUM,
// or
'target_database' => Relation::FORMAT_CROW,

```

### relations

[](#relations)

テーブル間のリレーションとその図示を定義します。 何もなくとも外部キー制約を元にリレーションを図示します。

- from : puml上の左辺。テーブル名
- to : puml上の右辺。テーブル名
- relation : 両者の関係。定数は\\Mysql2PlantUml\\app\\Models\\ValueObjects\\Relation::RELATION\_TYPESを参照。
- direction : puml上の関係線の伸ばす方向。定数は\\Mysql2PlantUml\\app\\Models\\ValueObjects\\Relation::DIRECTION\_TYPESを参照。
- arrowLength : puml上の関係線の長さ。常に($arrowLength &gt; 0) === true

```
    'relations' => [
        [
            'from' => 'hoge',
            'to' => 'fuga',
            'relation' => Relation::MANY_MANDATORY_TO_ONE_MANDATORY,
            'direction' => Relation::DIRECTION_LEFT,
            'arrowLength' => 4,
        ],
        [
            'from' => 'foo',
            'to' => 'bar',
            'relation' => Relation::ONE_MANDATORY_TO_ONE_MANDATORY,
            'direction' => Relation::DIRECTION_UP,
            'arrowLength' => 4,
        ],
    ],

```

### packages

[](#packages)

PlantUML上で複数テーブルをパッケージとしてまとめます。

```
    'packages' => [
        'hogefuga' => [
            'foo',
            'bar'
        ],
        'foobar' => [
            'hoge',
            'fuga'
        ]
    ]

```

### sub\_files

[](#sub_files)

特定のテーブルのみのPlantUMLファイルを作ります。

```
    'sub_files' => [
        'hoge.puml' => [
            'foo',
            'hoge',
        ],
        'fuga.puml' => [
            'foo',
            'bar',
            'fuga',
        ],
    ],

```

example
=======

[](#example)

sql
---

[](#sql)

```
create table migrations
(
    id        int unsigned auto_increment
        primary key,
    migration varchar(255) not null,
    batch     int          not null
)
    collate = utf8mb4_unicode_ci;

create table tags
(
    id    bigint unsigned auto_increment
        primary key,
    title varchar(255) not null
)
    collate = utf8mb4_unicode_ci;

create table task_tag
(
    task_id bigint unsigned not null,
    tag_id  bigint unsigned not null,
    constraint task_tag_custom_task_id_foreign
        foreign key (task_id) references tasks (id),
    constraint task_tag_tag_id_foreign
        foreign key (tag_id) references tags (id)
)
    collate = utf8mb4_unicode_ci;

create table tasks
(
    id      bigint unsigned auto_increment
        primary key,
    user_id bigint unsigned not null,
    content varchar(255)    not null,
    constraint tasks_user_id_unique
        unique (user_id),
    constraint tasks_user_id_foreign
        foreign key (user_id) references users (id)
            on update cascade on delete cascade
)
    collate = utf8mb4_unicode_ci;

create table users
(
    id   bigint unsigned auto_increment
        primary key,
    name varchar(255) not null
)
    collate = utf8mb4_unicode_ci;

```

plantuml
--------

[](#plantuml)

```
@startuml
skinparam {
defaultFontName Monospaced
}
left to right direction
package dacapo_sample {
entity "migrations" as migrations {
    + id       [PK]              int(10) unsigned  not null
      migration                  varchar(255)      not null
      batch                      int(11)           not null
}
entity "tags" as tags {
    + id   [PK]              bigint(20) unsigned  not null
      title                  varchar(255)         not null
}
entity "task_tag" as task_tag {
    # task_id    [FK]    [MUL] bigint(20) unsigned  not null
    # tag_id     [FK]    [MUL] bigint(20) unsigned  not null
}
entity "tasks" as tasks {
    + id     [PK]              bigint(20) unsigned  not null
    # user_id    [FK][UK]      bigint(20) unsigned  not null
      content                  varchar(255)         not null
}
entity "users" as users {
    + id  [PK]              bigint(20) unsigned  not null
      name                  varchar(255)         not null
}
}

task_tag }o-- tasks
task_tag }o-- tags
tasks }o-- users
@enduml
```dacapo_sample_ER.svg

```

ER図（puml to svg）
----------------

[](#er図puml-to-svg)

[![ER図](https://raw.githubusercontent.com/cpt-sugiura/laravel-mysql2plantuml/master/dacapo_sample_ER.svg)](https://raw.githubusercontent.com/cpt-sugiura/laravel-mysql2plantuml/master/dacapo_sample_ER.svg)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~83 days

Recently: every ~238 days

Total

16

Last Release

1091d ago

PHP version history (3 changes)1.0.0PHP ^7.2

1.9.1PHP ^7.2|^8.0

1.9.2PHP &gt;=7.2|&gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1136d8318899bb32a81a93d50afe3621d65daf93aef546eda888389777dabef?d=identicon)[cpt-sugiura](/maintainers/cpt-sugiura)

---

Top Contributors

[![cpt-sugiura](https://avatars.githubusercontent.com/u/49927277?v=4)](https://github.com/cpt-sugiura "cpt-sugiura (27 commits)")

---

Tags

laravelmysqlplantuml

### Embed Badge

![Health badge](/badges/molay76-laravel-mysql2plantuml/health.svg)

```
[![Health](https://phpackages.com/badges/molay76-laravel-mysql2plantuml/health.svg)](https://phpackages.com/packages/molay76-laravel-mysql2plantuml)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[itelmenko/laravel-mysql-logger

Laravel MySQL driver for Monolog

21141.9k](/packages/itelmenko-laravel-mysql-logger)[jrsaunders/shard-matrix

A Complete Database Sharding system for MYSQL and/or Postgres. Using Laravels Query Builder easily scale up your application. Configure your whole solution in one Yaml Config file.

271.5k](/packages/jrsaunders-shard-matrix)[addapp/laravel-query-log

Logs full mysql queries.

135.4k](/packages/addapp-laravel-query-log)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

101.6k](/packages/ramadan-easy-model)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
