Search code examples
laravelentity-relationship

Laravel ER diagram generator getAllModelsFromEachDirectory()


When I try to follow the instruction here (https://github.com/beyondcode/laravel-er-diagram-generator) I get the following error.

Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to BeyondCode\ErdGenerator\GenerateDiagramCommand::getAllModelsFromEachDirectory() must be of the type array, null given, called in vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php on line 96

 at vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:101
     97|
     98|         return $modelsFromDirectories;
     99|     }
    100|
    101|     protected function getAllModelsFromEachDirectory(array $directories): Collection
    102|     {
    103|         return collect($directories)
    104|             ->map(function ($directory) {
    105|                 return $this->modelFinder->getModelsInDirectory($directory)->all();

Exception trace:

1 BeyondCode\ErdGenerator\GenerateDiagramCommand::getAllModelsFromEachDirectory() vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:96

2 BeyondCode\ErdGenerator\GenerateDiagramCommand::getModelsThatShouldBeInspected() vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:57

Please use the argument -v to see more details.

I've already opened an issue in the repository.

Screen capture of the error:


Solution

  • Posting for others that may encounter same issue.

    1. Confirm you are using the version 1.4.0 or greater of the library

    2. Also if you're using php artisan serve try to stop the server. Run php artisan config:cache, and restart the artisan sever.

      Note that the reason why you might need to run php artisan config:cache is because Laravel does cache the app's configurations. if you changed or added new configurations you might explicitly need to clear the configuration cache so that Laravel can cache the new configurations.

    3. If no solution yet. Try this php artisan vendor:publish --provider=BeyondCode\\ErdGenerator\\ErdGeneratorServiceProvider. Then repeat step 2.