Package Data | |
---|---|
Maintainer Username: | kevincobain2000 |
Maintainer Contact: | kevincobain2000@gmail.com (Pulkit Kathuria) |
Package Create Date: | 2021-07-24 |
Package Last Update: | 2024-02-26 |
Home Page: | https://medium.com/web-developer/laravel-automatically-generate-interactive-erd-from-eloquent-relations-83fe65440716 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-18 03:00:41 |
Package Statistics | |
---|---|
Total Downloads: | 201,506 |
Monthly Downloads: | 4,171 |
Daily Downloads: | 83 |
Total Stars: | 141 |
Total Watchers: | 4 |
Total Forks: | 27 |
Total Open Issues: | 1 |
Automatically generate interactive ERD from Models relationships in Laravel.
| Lang | Link | | :------ | :------------------------------------------------------------------------------------------------------------------------------------- | | Details | Medium Article | | Demo | Online Demo |
| Lang | Version | | :------ | :--------- | | PHP | 7.4 or 8.0 | | Laravel | 6.* or 8.* |
You can install the package via composer:
composer require kevincobain2000/laravel-erd --dev
You can publish the config file with:
php artisan vendor:publish --provider="Kevincobain2000\LaravelERD\LaravelERDServiceProvider"
You can access the ERD in localhost:3000/erd
or generate a static HTML
php artisan erd:generate
ERD HTML is generated inside docs/
.
use Kevincobain2000\LaravelERD\LaravelERD;
$modelsPath = base_path('app/Models');
$laravelERD = new LaravelERD();
$linkDataArray = $laravelERD->getLinkDataArray($modelsPath);
$nodeDataArray = $laravelERD->getNodeDataArray($modelsPath);
$erdData = json_encode(
[
"link_data" => $linkDataArray,
"node_data" => $nodeDataArray,
],
JSON_PRETTY_PRINT
);
var_dump($erdData);
Sample JSON output
{
"link_data": [
{
"from": "comments",
"to": "users",
"fromText": "1..1\nBT",
"toText": "",
"fromPort": "author_id",
"toPort": "id",
"type": "BelongsTo"
},
{
"from": "comments",
"to": "posts",
"fromText": "1..1\nBT",
"toText": "",
"fromPort": "post_id",
"toPort": "id",
"type": "BelongsTo"
},
...
...
],
"node_data": [
{
"key": "comments",
"schema": [
{
"name": "id",
"isKey": true,
"figure": "Hexagon",
"color": "#be4b15",
"info": "integer"
},
{
"name": "author_id",
"isKey": false,
"figure": "Decision",
"color": "#6ea5f8",
"info": "integer"
},
...
...
}
...
]
./vendor/bin/phpunit