-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
196 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* text=auto | ||
|
||
/.github export-ignore | ||
/demo export-ignore | ||
/tests export-ignore | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.nitpick.json export-ignore |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Laravel ERD | ||
|
||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/recca0120/laravel-erd.svg?style=flat-square)](https://packagist.org/packages/recca0120/laravel-erd) | ||
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/recca0120/laravel-erd/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/recca0120/laravel-erd/actions?query=workflow%3Arun-tests+branch%3Amain) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/recca0120/laravel-erd.svg?style=flat-square)](https://packagist.org/packages/recca0120/laravel-erd) | ||
|
||
Laravel ERD automatically generates Entity-Relationship Diagrams from your Laravel models and displays them | ||
using [Vuerd](https://github.com/dineug/erd-editor). | ||
|
||
## Preview | ||
|
||
Here's a sample of what you can expect, generated from [migrations](database/migrations) | ||
and [models](tests/Fixtures/Models): | ||
|
||
> [View Live Demo](https://previewhtml.github.io/?url=https%3A%2F%2Fgithub.com%2Frecca0120%2Flaravel-erd%2Fblob%2Fmain%2Fdemo%2Findex.html) | ||
![Vuerd](demo/vuerd.jpg) | ||
|
||
## Requirements | ||
|
||
| Lang | Version | | ||
|:--------|:------------------------| | ||
| PHP | 7.4, 8.0, 8.1, 8.2, 8.3 | | ||
| Laravel | 8, 9, 10, 11 | | ||
|
||
## Installation | ||
|
||
Install the package via Composer: | ||
|
||
```bash | ||
composer require recca0120/laravel-erd:^0.1 --dev | ||
``` | ||
|
||
## Usage | ||
|
||
### Step 1: Generate the ERD | ||
|
||
Run the following command: | ||
|
||
```bash | ||
php artisan erd:generate | ||
``` | ||
|
||
Step 2: View the ERD | ||
|
||
Open the following URL in your browser: | ||
|
||
http://localhost/laravel-erd | ||
|
||
## Advanced Usage | ||
|
||
### Exclude Tables and Save to a Different Filename | ||
|
||
#### step 1. | ||
|
||
Run the command: | ||
|
||
```bash | ||
php artisan erd:generate --file=exclude-users.sql --exclude=users | ||
``` | ||
|
||
#### step 2. | ||
|
||
Open the URL: | ||
|
||
http://localhost/laravel-erd/exclude-users | ||
|
||
### Generate an SVG Version | ||
|
||
#### step 1. | ||
|
||
Install [erd-go](https://github.com/kaishuu0123/erd-go) | ||
and [graphviz-dot.js](https://github.com/kaishuu0123/graphviz-dot.js) using: | ||
|
||
```bash | ||
php artisan erd:install | ||
``` | ||
|
||
#### step 2. | ||
|
||
Generate the SVG file: | ||
|
||
```php | ||
php artisan generate --file=laravel-erd.svg | ||
``` | ||
|
||
#### step 3. | ||
|
||
View the SVG version: | ||
|
||
http://localhost/laravel-erd/laravel-erd.svg | ||
|
||
![svg](tests/Fixtures/expected_artisan.svg) | ||
|
||
> The SVG file can be found at storage/framework/cache/laravel-erd. | ||
Feel free to ask if you have any questions or need further assistance! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Laravel Erd</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
height: 100vh; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<erd-editor automatic-layout></erd-editor> | ||
<script> | ||
function loadScript(src, fallback, callback) { | ||
const script = document.createElement('script'); | ||
if (callback) { | ||
script.onload = () => callback(); | ||
} | ||
|
||
if (fallback) { | ||
script.onerror = () => loadScript(fallback, undefined, callback); | ||
} | ||
|
||
script.src = src; | ||
document.body.appendChild(script); | ||
} | ||
|
||
function init() { | ||
const editor = document.querySelector('erd-editor'); | ||
editor.loadSQLDDL(atob('Q1JFQVRFIFRBQkxFIGNhcnMgKAogICAgaWQgaW50ZWdlcigxMSkgTk9UIE5VTEwgQVVUT19JTkNSRU1FTlQsCiAgICBtb2RlbCB2YXJjaGFyKDI1NSkgTk9UIE5VTEwsCiAgICBtZWNoYW5pY19pZCBpbnRlZ2VyKDExKSBOT1QgTlVMTCwKICAgIFBSSU1BUlkgS0VZKGlkKQopCkNSRUFURSBUQUJMRSBjb21tZW50cyAoCiAgICBpZCBpbnRlZ2VyKDExKSBOT1QgTlVMTCBBVVRPX0lOQ1JFTUVOVCwKICAgIHBvc3RfaWQgaW50ZWdlcigxMSkgTk9UIE5VTEwsCiAgICB0aXRsZSB2YXJjaGFyKDI1NSkgTk9UIE5VTEwsCiAgICBjcmVhdGVkX2F0IGRhdGV0aW1lLAogICAgdXBkYXRlZF9hdCBkYXRldGltZSwKICAgIFBSSU1BUlkgS0VZKGlkKQopCkNSRUFURSBUQUJMRSBpbWFnZXMgKAogICAgaWQgaW50ZWdlcigxMSkgTk9UIE5VTEwgQVVUT19JTkNSRU1FTlQsCiAgICB1cmwgdmFyY2hhcigyNTUpIE5PVCBOVUxMLAog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CkFMVEVSIFRBQkxFIG1vZGVsX2hhc19wZXJtaXNzaW9ucyBBREQgRk9SRUlHTiBLRVkgKG1vZGVsX2lkKSBSRUZFUkVOQ0VTIHVzZXJzIChpZCkKQUxURVIgVEFCTEUgbW9kZWxfaGFzX3Blcm1pc3Npb25zIEFERCBGT1JFSUdOIEtFWSAocGVybWlzc2lvbl9pZCkgUkVGRVJFTkNFUyBwZXJtaXNzaW9ucyAoaWQpCkFMVEVSIFRBQkxFIG1vZGVsX2hhc19yb2xlcyBBREQgRk9SRUlHTiBLRVkgKG1vZGVsX2lkKSBSRUZFUkVOQ0VTIHVzZXJzIChpZCkKQUxURVIgVEFCTEUgbW9kZWxfaGFzX3JvbGVzIEFERCBGT1JFSUdOIEtFWSAocm9sZV9pZCkgUkVGRVJFTkNFUyByb2xlcyAoaWQpCkFMVEVSIFRBQkxFIHBlcm1pc3Npb25zIEFERCBGT1JFSUdOIEtFWSAoaWQpIFJFRkVSRU5DRVMgcm9sZV9oYXNfcGVybWlzc2lvbnMgKHBlcm1pc3Npb25faWQpCkFMVEVSIFRBQkxFIHBob25lcyBBREQgRk9SRUlHTiBLRVkgKHVzZXJfaWQpIFJFRkVSRU5DRVMgdXNlcnMgKGlkKQpBTFRFUiBUQUJMRSBwb3N0cyBBREQgRk9SRUlHTiBLRVkgKHVzZXJfaWQpIFJFRkVSRU5DRVMgdXNlcnMgKGlkKQpBTFRFUiBUQUJMRSByb2xlX2hhc19wZXJtaXNzaW9ucyBBREQgRk9SRUlHTiBLRVkgKHJvbGVfaWQpIFJFRkVSRU5DRVMgcm9sZXMgKGlkKQ==')); | ||
} | ||
|
||
loadScript('../resources/dist/vuerd.min.js', 'https://cdn.jsdelivr.net/npm/vuerd/dist/vuerd.min.js', init); | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/BaseModel.php → tests/Fixtures/Models/BaseModel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Comment.php → tests/Fixtures/Models/Comment.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Device.php → tests/Fixtures/Models/Device.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Image.php → tests/Fixtures/Models/Image.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Mechanic.php → tests/Fixtures/Models/Mechanic.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Other/BaseModel.php → tests/Fixtures/Models/Other/BaseModel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Other/Car.php → tests/Fixtures/Models/Other/Car.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Other/Mechanic.php → tests/Fixtures/Models/Other/Mechanic.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Other/Owner.php → tests/Fixtures/Models/Other/Owner.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Owner.php → tests/Fixtures/Models/Owner.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Phone.php → tests/Fixtures/Models/Phone.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/Post.php → tests/Fixtures/Models/Post.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/fixtures/Models/User.php → tests/Fixtures/Models/User.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
namespace Recca0120\LaravelErd\Tests\Fixtures; | ||
|
||
class NonModel {} |
File renamed without changes
Oops, something went wrong.