laravel-modules: Class "Illuminate\Database\Console\ShowModelCommand" not found

Hello,

Installing laravel-modules on Laravel 9.52.4, I get the following error:

$ composer require nwidart/laravel-modules
./composer.json has been updated
Running composer update nwidart/laravel-modules
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Error 

  Class "Illuminate\Database\Console\ShowModelCommand" not found

  at vendor/nwidart/laravel-modules/src/Commands/ModelShowCommand.php:9
      5▕ use Illuminate\Database\Console\ShowModelCommand;
      6▕ use Symfony\Component\Console\Attribute\AsCommand;
      7▕ 
      8▕ #[AsCommand('module:model-show', 'Show information about an Eloquent model in modules')]
  ➜   9▕ class ModelShowCommand extends ShowModelCommand
     10▕ {
     11▕ 
     12▕ 
     13▕     /**

      +2 vendor frames 
  3   [internal]:0
      Composer\Autoload\ClassLoader::loadClass()

      +7 vendor frames 
  11  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

While inspecting th issue, I found that \Nwidart\Modules\Commands\ModelShowCommand uses Illuminate\Database\Console\ShowModelCommand, which is not there any more.

See: https://laravel.com/api/9.x/Illuminate/Database/Console.html

EDIT: I see now that for version Laravel 9 we should use laravel-modules 9 also, sorry about the mistake.

Best regards, Khalid Muharam.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16

Most upvoted comments

I think composer require "nwidart/laravel-modules":"9.*" will do, depending on your Laravel version.

Hello @andreamanini

You need to edit your composer.json file, specify the package version compatible with your Laravel version.

{
...
    "require": {
...
        "nwidart/laravel-modules": "9.*",
...
    }
...
}

If you experience problems try running with the --no-scripts flag:

composer update --no-scripts

or

composer install --no-scripts