php 生成关系图,Laravel ER Diagram Generator:从Laravel模型文件生成实体关系图

Laravel ER Diagram Generator

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265796f6e64636f64652f6c61726176656c2d65722d6469616772616d2d67656e657261746f722e7376673f7374796c653d666c61742d73717561726568747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6265796f6e64636f64652f6c61726176656c2d65722d6469616772616d2d67656e657261746f722f6d61737465722e7376673f7374796c653d666c61742d73717561726568747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6265796f6e64636f64652f6c61726176656c2d65722d6469616772616d2d67656e657261746f722e7376673f7374796c653d666c61742d73717561726568747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265796f6e64636f64652f6c61726176656c2d65722d6469616772616d2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265

This package lets you generate entity relation diagrams by inspecting the relationships defined in your model files. It is highly customizable. Behind the scenes, it uses GraphViz to generate the graph.

If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course.

Prerequisites

The minimum required PHP version is 7.1.0.

Requirements

This package requires the graphviz tool.

You can install Graphviz on MacOS via homebrew:

brew install graphviz

Or, if you are using Homestead:

sudo apt-get install graphviz

To install Graphviz on Windows, download it from the official website.

Installation

You can install the package via composer:

composer require beyondcode/laravel-er-diagram-generator --dev

If you are using Laravel 5.5+, the package will automatically register the service provider for you.

If you are using Lumen, you will need to add the following to bootstrap\app.php:

\\ Register Service Providers

$app->register(BeyondCode\ErdGenerator\ErdGeneratorServiceProvider::class);

Usage

By default, the package will automatically detect all models in your app directory that extend the Eloquent Model class. If you would like you explicitly define where your models are located, you can publish the configuration file using the following command.

php artisan vendor:publish --provider=BeyondCode\\ErdGenerator\\ErdGeneratorServiceProvider

If you're using Lumen and you want to customize the config, you'll need to copy the config file from the vendor directory:

cp ./vendor/beyondcode/laravel-er-diagram-generator/config/config.php config/erd-generator.php

Generating Diagrams

You can generate entity relation diagrams using the provided artisan command:

php artisan generate:erd

This will generate a file called graph.png.

You can also specify a custom filename:

php artisan generate:erd output.png

Or use one of the other output formats, like SVG:

php artisan generate:erd output.svg --format=svg

Customization

Please take a look at the published erd-generator.php configuration file for all available customization options.

Examples

Here are some examples taken from the Laravel.io codebase.

d8d6609d9e852e93c9d0cf3c97be899a.png

4a05f184f65e73831f49206dc7f26428.png

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email marcel@beyondco.de instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值