Coder Social home page Coder Social logo

laravel-er-diagram-generator's Introduction

Laravel ER Diagram Generator

Latest Version on Packagist Total Downloads

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/Models 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.

Using Database Schema

Customized

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 [email protected] instead of using the issue tracker.

Credits

License

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

laravel-er-diagram-generator's People

Contributors

daniel-werner avatar diogogomeswww avatar drbyte avatar eiko03 avatar henryavila avatar iforwms avatar joe-pritchard avatar laravel-shift avatar mechelon avatar mpociot avatar niclasvaneyk avatar orkhanahmadov avatar pascalbaljet avatar rdarcy1 avatar simondavies avatar thibauddauce avatar yahav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-er-diagram-generator's Issues

Recursive path + class exclusions

It would be convenient to be able to specify a single model directory and have it traversed recursively.

In our app, we have 5 subdirectories and adding one to the configuration can easily get missed.

One way to implement that, and stay backwards compatible with current configs could be to specify the folders as key/values.

E.g.

[
  app_path('Models') => [
    'recursive' => true, // key/value to pass settings
  ],
  app_path('Models'), // no key means just use default options for that folder
]

Stylizing graph

Hello,

Someone knows good settings for generate a beautiful diagram?

Thanks for reply?

MorhpTo could not be converted to string

I have a very small application with 2 classes and they have a one-to-one polymorphic relationship. When removing the $this->morhTo() the diagram is generated, but no matter what I do, adding a polymorphic relationship gives me this error below. I'm using Laravel 5.8.10

Did something change in the latest versions?

`Found 2 models.
Inspecting model relations.
2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%PHP Fatal error: Method BeyondCode\ErdGenerator\Edge::__toString() must not throw an exception, caught ErrorException: Object of class Illuminate\Database\Eloquent\Relations\MorphTo could not be converted to string in /home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php on line 0
PHP Stack trace:
PHP 1. {main}() /home/felion/doctorapp/artisan:0
PHP 2. App\Console\Kernel->handle() /home/felion/doctorapp/artisan:37
PHP 3. Illuminate\Console\Application->run() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122
PHP 4. Illuminate\Console\Application->run() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Console/Application.php:90
PHP 5. Illuminate\Console\Application->doRun() /home/felion/doctorapp/vendor/symfony/console/Application.php:145
PHP 6. Illuminate\Console\Application->doRunCommand() /home/felion/doctorapp/vendor/symfony/console/Application.php:269
PHP 7. BeyondCode\ErdGenerator\GenerateDiagramCommand->run() /home/felion/doctorapp/vendor/symfony/console/Application.php:908
PHP 8. BeyondCode\ErdGenerator\GenerateDiagramCommand->run() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
PHP 9. BeyondCode\ErdGenerator\GenerateDiagramCommand->execute() /home/felion/doctorapp/vendor/symfony/console/Command/Command.php:255
PHP 10. Illuminate\Foundation\Application->call() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
PHP 11. Illuminate\Container\BoundMethod::call() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:580
PHP 12. Illuminate\Container\BoundMethod::callBoundMethod() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
PHP 13. Illuminate\Container\BoundMethod::Illuminate\Container{closure:/home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:30-34}() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
PHP 14. call_user_func_array:{/home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32}() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
PHP 15. BeyondCode\ErdGenerator\GenerateDiagramCommand->handle() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
PHP 16. phpDocumentor\GraphViz\Graph->export() /home/felion/doctorapp/vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:77
PHP 17. phpDocumentor\GraphViz\Graph->__toString() /home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:363

Symfony\Component\Debug\Exception\FatalErrorException : Method BeyondCode\ErdGenerator\Edge::__toString() must not throw an exception, caught ErrorException: Object of class Illuminate\Database\Eloquent\Relations\MorphTo could not be converted to string

at /home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:0
1| <?php
2| /**
3| * phpDocumentor
4| *
5| * PHP Version 5
6| *
7| * @author Mike van Riel [email protected]
8| * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
9| * @license http://www.opensource.org/licenses/mit-license.php MIT

Exception trace:

1 Symfony\Component\Debug\Exception\FatalErrorException::__construct()
/home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:137

2 Illuminate\Foundation\Bootstrap\HandleExceptions::fatalExceptionFromError()
/home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:123

Please use the argument -v to see more details.

Whoops\Exception\ErrorException : Method BeyondCode\ErdGenerator\Edge::__toString() must not throw an exception, caught ErrorException: Object of class Illuminate\Database\Eloquent\Relations\MorphTo could not be converted to string

at /home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:0
1| <?php
2| /**
3| * phpDocumentor
4| *
5| * PHP Version 5
6| *
7| * @author Mike van Riel [email protected]
8| * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
9| * @license http://www.opensource.org/licenses/mit-license.php MIT

Exception trace:

1 phpDocumentor\GraphViz\Graph::__toString()
/home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:363

2 phpDocumentor\GraphViz\Graph::export()
/home/felion/doctorapp/vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:77

`

Relationships added with Macros

Relationships added dynamically with macros aren't shown

E.g.

\Illuminate\Database\Eloquent\Builder::macro('foo', function () {
    return $this->getModel()->morphMany(\App\Models\Foo::class, 'foable');
});

Found 0 models (Possibly unable to override config for directories)

Hi! Congrats and thanks for this pretty much convenient tool.

I've installed as instructed, but after running the command it seems to find no models. I've configured the proper directory and tried the text mode to help debug (As per this issue).

  • PHP 7.2.7
  • laravel/framework v5.6.26
$ php artisan generate:erd --format=text
Found 0 models.
Inspecting model relations.
digraph "G" {
style="filled"
bgcolor="#F7F7F7"
fontsize="12"
labelloc="t"
concentrate="1"
splines="polyline"
overlap=""
nodesep="1"
rankdir="LR"
pad="0.5"
ranksep="2"
esep="1"
fontname="Helvetica Neue"
}
// ./config/erd-generator.php
// ...
    'directories' => [
        app_path(),
    ],
// ...

I expect 8 models to be found:

$ ls --group-directories-first -1r app/
Validators
Traits
Providers
Policies
Patches
Observers
Notifications
Mail
Listeners
Http
FIMEDI
Exceptions
Events
Console
User.php
SaasQuota.php
Payment.php
Patient.php
Inspection.php
DeviceModel.php
Control.php
Account.php

Any possible clue is welcome. Thanks in advance!

Homestead compatibility

Worth noting that Homestead doesn't come out-of-the-box with Brew (or Graphviz).
Might be worth documenting it's simply a case of running sudo apt install linuxbrew-wrapper and sudo apt-get install graphviz before running brew install graphviz.

Not showing many to many relationship.

I have two models connected via pivot table in a many to many relationship where any number of webpages can be connected to any number of images. Setup as per the docs here: https://laravel.com/docs/5.6/eloquent-relationships#many-to-many

All other relations display on the graph as expected, which is very nice, thank you!

App\Image.php

    /**
     * @return mixed
     */
    public function webpages()
    {
        return $this->belongsToMany(Webpage::class)->withTimestamps();
    }

App\Webpage.php

    /**
     * @return mixed
     */
    public function images()
    {
        return $this->belongsToMany(Image::class)->withTimestamps();
    }

Any idea what I am missing?

Taking it more into width than height

Hey there!
First of all: Great work, it seems to work like a charme. It saves so much time when it comes to manually documenting all of that stuff.

However, due to the way it is made, it is kind of hard for bigger projects to use it. I've tried it for one of our projects which is currently in development, and you can see the clear dimensions of the size here:

http://prntscr.com/k21hem

Maybe there is a way of extending it more into the width instead of height. This would make it much more usefull when it comes to using it.

Nontheless, really great work and appreciate it!

Include types

It would be nice if there was an option to include types alongside column names.

Really cool diagrams, btw!

[Question] Disable some relationships on graph

Usually on two models we have hasMany() / belongsTo() combination.

But, on graphs would be useful a option to disable belongsTo (eg) to keep it clear and easy to read. The hasMany would be enough to know the inverse relationship, implicit. On complex apps it can be harder.

Another useful config would be hide relationship names.

Database entity blank

After generated Laravel ER diagram successfully, it shows the tables relationship but didn't show database entity.

table

Including pivot tables

Using a belongsToMany relationship doesn't include the pivot table on the generated diagram. It would be useful if they could be, especially where there are extra columns on the pivot table.

Exception for sh1 dot not found

Hello, and first of all thank you for creating such a great package. I am looking forward to use it in our team for thorough documentation.

However, I am encountering an Exception and I am not sure which way to go now. Could you take a look with me and point me in the right direction please?

The command I use is php artisan generate:erd and the output is:
dot not found

I see that it might have to do with 'dot' in https://github.com/phpDocumentor/GraphViz/blob/master/src/phpDocumentor/GraphViz/Graph.php#L336


Other information that might be useful:

I use the standard erd-generator.php config that was copied during the installation.
In this config file I only changed the content of the array 'directories':

    'directories' => [
         app_path('Models'),
         app_path('Models/*'),
         app_path('Models/*/*'),
    ],

The library 'laravel/framework' in use is version 5.6.16

In composer.json this entry was added in the 'require-dev' section:
"beyondcode/laravel-er-diagram-generator": "^0.2.2"

In composer.lock the following packages were automatically installed together with yours:

  • doctrine/annotations version 1.6.0
  • doctrine/cache version 1.7.1
  • doctrine/collections version 1.5.0
  • doctrine/common version 2.8.1
  • doctrine/dbal version 2.7.1
  • phpdocumentor/graphviz version 1.0.4

Operating System: Linux/Ubuntu 16.04

Found 0 models.

After running command php artisan generate:erd
it say that:
"
Found 0 models.
Inspecing model relations.
Wrote diagram to graph.png
"

Error

Hello,

I have a pretty big app with a lot of models/relations.

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

i get the following error:

95/95 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
   phpDocumentor\GraphViz\Exception  : An error occurred while creating the graph; GraphViz returned: Error: <stdin>: syntax error in line 35 near '\'

  at /Users/rf/workspace/pmp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:375
    371|         exec($this->path . "dot -T$type -o$filename < $tmpfileArg 2>&1", $output, $code);
    372|         unlink($tmpfile);
    373| 
    374|         if ($code != 0) {
  > 375|             throw new Exception(
    376|                 'An error occurred while creating the graph; GraphViz returned: '
    377|                 . implode(PHP_EOL, $output)
    378|             );
    379|         }

  Exception trace:

  1   phpDocumentor\GraphViz\Graph::export("'svg'", "'output.svg'")
      /Users/rf/workspace/pmp/vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:75

  2   BeyondCode\ErdGenerator\GenerateDiagramCommand::handle()
      /Users/rf/workspace/pmp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

  Please use the argument -v to see more details.

Relationships defined in parent class + ignore abstract classes

Some of our models extend a common base class which defines a relationship for all of them.

These relationships are not taken into account in the graph.

For instance:

class Participant extends Model {
    public function details() : MorphOne 
}

abstract class ParticipantDetails extends Model {
    public function participant() : MorphOne 
}

class PlayerDetails extends ParticipantDetails {
    // inherits the participant relationship
}

class RefereeDetails extends ParticipantDetails {
    // inherits the participant relationship
}

I think that any abstract class could be safely ignored.

And the inherited relationship should be pulled in each concrete class.

memory_limit issue

Found 22 models.
Inspecting model relations.
14/22 [=================>----------] 63%PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in C:\xampp\htdocs\zedshoply\vendor\laravel\framewor
k\src\Illuminate\Database\Eloquent\Concerns\HasRelationships.php on line 656
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 8192 bytes) in C:\xampp\htdocs\zedshoply\vendor\monolog\monolog\src\Monolog\Formatter\LineFormatter.php on
line 142

what i did:
i edited php.ini and set memory_limit to 1G
still got error
then i tried to edit the monolog source and added this line
ini_set("memory_limit", -1);

still same error

json output

I have an idea to build an interactive visualization of an ERD using d3. it would be awesome if we could get access to a raw json output of the relationships backing the svg generator.

it looks like phpDocumentor may already have support for that phpDocumentor/phpDocumentor#1446

Only seeing BelongsToMany relations, Laravel 5.3.31. PHP 7.1.19

I'm only seeing BelongsToMany relations in the generated image. I'm using the default config with an added relation:

'relations' => [
'HasOne' => [
'dir' => 'both',
'color' => '#D62828',
'arrowhead' => 'tee',
'arrowtail' => 'none',
],
'BelongsTo' => [
'dir' => 'both',
'color' => '#F77F00',
'arrowhead' => 'tee',
'arrowtail' => 'crow',
],
'HasMany' => [
'dir' => 'both',
'color' => '#FCBF49',
'arrowhead' => 'crow',
'arrowtail' => 'none',
],
'BelongsToMany' => [
'dir' => 'both',
'color' => '#F77F00',
'arrowhead' => 'tee',
'arrowtail' => 'none',
],
'MorphTo' => [
'dir' => 'both',
'color' => '#F77F00',
'arrowhead' => 'tee',
'arrowtail' => 'none',
]
]

Multiple diagrams

Hello,

First of all, thanks for you package, it's really easy to use and save us some time in our projet !
I would like to know if there is a way to generate multiple diagrams, based on parts of models used in the app to get a more focused view of some relations in our application ?

Thx in advance !
Have a nice day !

recurring problem with underscores

Hi there,

I have plenty of model named using _ especially type prefix_model.

Laravel er diagram do not work on it. It seems they are transformed into - (using the output in txt format) which cannot be read or is causing problem to graphviz.

How could this be solved.

Use Reflection before invoking the method

Invoking directly the method code can lead to unexpected code execution. Before executing the method a great filter could be the use of ReflectionFunctionAbstract::getReturnType. If not mandatory i think it sould be at least configurable.

Anyway, great package!

An error occurred while creating the graph

phpDocumentor\GraphViz\Exception : An error occurred while creating the graph; GraphViz returned: sh: 1: dot: not found

Exception trace:

1 phpDocumentor\GraphViz\Graph::export("'png'", "'output.png'")
.../vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:77

2 BeyondCode\ErdGenerator\GenerateDiagramCommand::handle()
.../vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

An error occurred while creating the graph; GraphViz returned: Error: <stdin>: syntax error in line 55 near '-'

php artisan generate:erd
Found 127 models.
Inspecting model relations.
127/127 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
In Graph.php line 375:

An error occurred while creating the graph; GraphViz returned: Error: : syntax error in line 55 near '-'

tried to debug using txt format, but output.txt file is not created and from terminal i do not see whole generated json file

Generation is made from mac os x mojave with php 7.2 and laravel 5.6.39

Running the command cleared my Algolia Indices

Hi,

Yesterday I tried to run the command. I got the following error

[2019-09-10 14:53:40] local.ERROR: An error occurred while creating the graph; GraphViz returned: sh: dot: command not found {"exception":"[object] (phpDocumentor\\GraphViz\\Exception(code: 0): An error occurred while creating the graph; GraphViz returned: sh: dot: command not found at /Users/jamesmills/Projects/flights/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:375)

I didn't think much of it and I just decided to look at it again another time. Then a few hours later I was alerted to the fact that our search was not working on our website. I looked at the Algolia logs and it looks like my application send a 'clear indices' command at the same time I ran the generate:erd command. Granted, I should have my admin Algolia key commented out in development to prevent anything odd happening like this but I thought it was odd that this would happen.

I can only think that when the package loads up and looks at the Model the interaction that it had made it look like it was clearing, deleting or that there were no records for the Model and then Scout/Algolia cleared my live index.

Just wanted to make you aware of this. I have not had the time to dig into it any further.

James

Getting PhpParser\Error : Syntax error, unexpected ',' on line 153 while running php artisan generate:erd

Hi,
I am trying to run php artisan generate:erd for my project and getting the below error.

PhpParser\Error : Syntax error, unexpected ',' on line 153

at /var/www/app/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:315
311| /* error */
312| switch ($this->errorState) {
313| case 0:
314| $msg = $this->getErrorMessage($symbol, $state);

315| $this->emitError(new Error($msg, $startAttributes + $endAttributes));
316| // Break missing intentionally
317| case 1:
318| case 2:
319| $this->errorState = 3;

Exception trace:

1 PhpParser\ParserAbstract::doParse()
/var/www/app/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:158

2 PhpParser\ParserAbstract::parse("<?php namespace App\Http\Controllers;

Please let me know why am I getting this error?

An error occurred while creating the graph; GraphViz returned: Error: <stdin>: syntax error in line 1213 near '->'

php artisan generate:erd -vvv
Found 148 models.
Inspecting model relations.
148/148 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 51 mins/51 mins 1.9 GiB
In Graph.php line 375:

[phpDocumentor\GraphViz\Exception]
An error occurred while creating the graph; GraphViz returned: Error: : syntax error in line 1213 near '->'

Exception trace:
() at /var/www/api/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:384
phpDocumentor\GraphViz\Graph->export() at /var/www/api/vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:77
BeyondCode\ErdGenerator\GenerateDiagramCommand->handle() at n/a:n/a
call_user_func_array() at /var/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
Illuminate\Container\BoundMethod::Illuminate\Container{closure}() at /var/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
Illuminate\Container\BoundMethod::callBoundMethod() at /var/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
Illuminate\Container\BoundMethod::call() at /var/www/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:564
Illuminate\Container\Container->call() at /var/www/api/vendor/laravel/framework/src/Illuminate/Console/Command.php:179
Illuminate\Console\Command->execute() at /var/www/api/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/api/vendor/laravel/framework/src/Illuminate/Console/Command.php:166

ID parameter is required for GetObject() request

php artisan generate:erd
Found 219 models.
Inspecting model relations.
43/219 [▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░] 19%Re-importing photo for ..
Building not found on condos by name.
121/219 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░] 55%REMOVE TEMPS FOR ACTUAL USE
155/219 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░] 70%ID parameter is required for GetObject() request.
... and crashes. tried it with -vvv option for Debug verbose printout but don't get any more clues.
Any help would be appreciated.

Freezing on a Particular Model

▶ php artisan generate:erd
Found 43 models.
Inspecting model relations.
 38/43 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░]  88%

Is there a way to provide more robust progress so I can see what model is causing this to stall? Using the -vvv switch just shows the data rates.

[5.8] BelongsTo relationships are not displayed on the diagram

BelongsTo relationships are not displayed on the diagram.


By dumping the catched Throwable in RelationFinder::getRelationshipFromMethodAndModel(), I got the following message:

Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::getForeignKey()

Offending line:

$localKey = $return->getForeignKey();


It's probably been the case since laravel/framework@2ee1892 changed the BelongsTo API:

command generate

hi,

when I put the command
php artisan generate:erd

the console say
There are no commands defined in the "generate" namespace.

I think the command generate doesn't exist on artisan cli.
it's true?

Trait Issues

It seems to have an issue with some traits:

Type error: Argument 1 passed to BeyondCode\ErdGenerator\GenerateDiagramCommand::BeyondCode\ErdGenerator\{closure}() must be an instance of ReflectionMethod, instance of Illuminate\Support\Collection given

It threw the above exception on SoftDeletes and CanResetPassword traits. I commented them out and it ran but didn't show the relations. I will note the project I ran it on has over 100 models.

ParserAbstract.php error

In ParserAbstract.php line 313:
Syntax error, unexpected T_LIST, expecting T_STRING on line 7

Up the patch version for Laravel 6 support

Currently we still cannot use Laravel 6 with 1.3.0. We get the
Call to undefined function BeyondCode\ErdGenerator\array_get() error:
image

#60 PR (which is merged) fixes this issue. However we cannot use it until the composer version is upped.

Models not found if they have declare(strict_types=1)

All of my models start with the strict types declaration, and when I run the generator I see Models found: 0.

Anyone with strict types declared in only some of their model classes would see those models being omitted from the diagram.

This is because the strict types declaration throws off the ModelFinder::getFullyQualifiedClassNameFromFile method since it looks in the first element in $statements, which in my case is the strict types declaration and not the body of the class. It's a simple fix, I'll submit a PR :)

can you add mongodb support please ?

please can you do somethings like

use Doctrine\DBAL\Schema\Column;

class GraphBuilder
{
     protected function getTableColumnsFromModel(string $model)
    {
        try {

            $model = app($model);

            switch ($model->getConnectionName()) {

                case 'mongodb':

                    if (method_exists($model, 'columns')) {
                        $columns = $model::columns();
                        $colloction = new Collection();
                        foreach ($columns as $column => $type) {
                            $column = new Column($column, $type);
                            $colloction->push($column);
                        }

                        return $colloction->toArray();
                    }
                    return [];
                default:
                    $table = $model->getConnection()->getTablePrefix().$model->getTable();
                    $schema = $model->getConnection()->getDoctrineSchemaManager($table);
                    $databasePlatform = $schema->getDatabasePlatform();
                    $databasePlatform->registerDoctrineTypeMapping('enum', 'string');

                    $database = null;

                    if (strpos($table, '.')) {
                        list($database, $table) = explode('.', $table);
                    }

                    return $schema->listTableColumns($table, $database);
            }
        } catch (\Exception $e) {

        }

        return [];
    }
}

and in the mongo model

/**
     * @return array|bool
     */
    protected static function columns()
    {
        try {
            return [
                'id' => Type::getType(Type::BIGINT),
                'component_type_id' => Type::getType(Type::BIGINT),
                'labels' => Type::getType(Type::TARRAY),
                'visualization_type' => Type::getType(Type::STRING),
                'created_at' => Type::getType(Type::DATETIMETZ),
                'data' => Type::getType(Type::JSON),
            ];
        } catch (\Exception $e) {
            if (config('app.debug')) {
                dd($e);
            }
            return false;
        }
    }

VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.

Hi, I want to export erd as an svg but I get the error shown below when I run php artisan generate:erd output.svg --format=svg command:

$ npm run erd

> @ erd D:\project
> php artisan generate:erd output.svg --format=svg

Found 24 models.
Inspecting model relations.
 22/24 [=========================>--]  91%
VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.


VirtualFree() failed: [0x000001e7] Attempt to access invalid address.


VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.


VirtualFree() failed: [0x000001e7] Attempt to access invalid address.

PHP Fatal error:  Out of memory (allocated 1369440256) (tried to allocate 4096 bytes) in D:\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php on line 119

VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.


VirtualFree() failed: [0x000001e7] Attempt to access invalid address.

PHP Fatal error:  Out of memory (allocated 1369440256) (tried to allocate 32768 bytes) in D:\project\vendor\laravel\framework\src\Illuminate\Auth\SessionGuard.php on line 598
npm ERR! code ELIFECYCLE
npm ERR! errno 255
npm ERR! @ erd: `php artisan generate:erd output.svg --format=svg`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the @ erd script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ROG\AppData\Roaming\npm-cache\_logs\2018-10-02T10_18_17_878Z-debug.log

Tried to set memory_limit=-1 but it didn't help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.