Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 7 - ModuleNotFoundException #995

Closed
nabeelio opened this issue May 22, 2020 · 28 comments
Closed

Laravel 7 - ModuleNotFoundException #995

nabeelio opened this issue May 22, 2020 · 28 comments

Comments

@nabeelio
Copy link

nabeelio commented May 22, 2020

Hi,

Testing after updating to Laravel 7, running into a few issues, mainly this one has me stumped:

$ php artisan module:make TestModule;
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/module.json
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Routes/web.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Routes/api.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Routes/admin.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Providers/AppServiceProvider.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Providers/EventServiceProvider.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Providers/RouteServiceProvider.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Resources/views/index.blade.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Resources/views/admin/index.blade.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Resources/views/layouts/frontend.blade.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Resources/views/layouts/admin.blade.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Listeners/TestEventListener.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Controllers/Frontend/IndexController.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Controllers/Api/ApiController.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Controllers/Admin/AdminController.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Config/config.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/composer.json
[2020-05-22T18:39:50.366694+00:00] dev.ERROR: Module [TestModule] does not exist! {"exception":"[object] (Nwidart\\Modules\\Exceptions\\ModuleNotFoundException(code: 0): Module [TestModule] does not exist! at /Users/nabeelshahzad/dev/nabeelio/phpvms/vendor/nwidart/laravel-modules/src/FileRepository.php:396)"} []

   Nwidart\Modules\Exceptions\ModuleNotFoundException

  Module [TestModule] does not exist!

  at vendor/nwidart/laravel-modules/src/FileRepository.php:396
    392|         if ($module !== null) {
    393|             return $module;
    394|         }
    395|
  > 396|         throw new ModuleNotFoundException("Module [{$name}] does not exist!");
    397|     }
    398|
    399|     /**
    400|      * Get all modules as laravel collection instance.

      +31 vendor frames
  32  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

It looks like all the files I'm expecting are generated:

modules/TestModule
├── Config
│   └── config.php
├── Console
├── Database
│   ├── factories
│   ├── migrations
│   └── seeds
├── Http
│   ├── Controllers
│   │   ├── Admin
│   │   │   └── AdminController.php
│   │   ├── Api
│   │   │   └── ApiController.php
│   │   └── Frontend
│   │       └── IndexController.php
│   ├── Middleware
│   ├── Requests
│   └── Routes
│       ├── admin.php
│       ├── api.php
│       └── web.php
├── Listeners
│   └── TestEventListener.php
├── Models
├── Providers
│   ├── AppServiceProvider.php
│   ├── EventServiceProvider.php
│   └── RouteServiceProvider.php
├── Resources
│   ├── assets
│   ├── lang
│   └── views
│       ├── admin
│       │   └── index.blade.php
│       ├── index.blade.php
│       └── layouts
│           ├── admin.blade.php
│           └── frontend.blade.php
├── composer.json
├── module.json
└── tests

This is what my config looks like; I'm generating some extra files and scaffolding:

<?php

use Nwidart\Modules\Activators\FileActivator;

return [
    'namespace' => 'Modules',
    'stubs'     => [
        'enabled' => true,
        'path'    => resource_path().'/stubs/modules',
        'files'   => [
            'routes'                 => 'Http/Routes/web.php',
            'routes-api'             => 'Http/Routes/api.php',
            'routes-admin'           => 'Http/Routes/admin.php',
            'app-provider'           => 'Providers/AppServiceProvider.php',
            'event-service-provider' => 'Providers/EventServiceProvider.php',
            'route-provider'         => 'Providers/RouteServiceProvider.php',
            'views/index'            => 'Resources/views/index.blade.php',
            'views/index-admin'      => 'Resources/views/admin/index.blade.php',
            'views/frontend'         => 'Resources/views/layouts/frontend.blade.php',
            'views/admin'            => 'Resources/views/layouts/admin.blade.php',
            'listener-test'          => 'Listeners/TestEventListener.php',
            'controller'             => 'Http/Controllers/Frontend/IndexController.php',
            'controller-api'         => 'Http/Controllers/Api/ApiController.php',
            'controller-admin'       => 'Http/Controllers/Admin/AdminController.php',
            'config'                 => 'Config/config.php',
            'composer'               => 'composer.json',
        ],
        'replacements' => [
            'start'                  => ['LOWER_NAME', 'ROUTES_LOCATION'],
            'routes'                 => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
            'routes-api'             => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
            'json'                   => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
            'app-provider'           => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
            'event-service-provider' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CLASS_NAMESPACE'],
            'route-provider'         => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CLASS_NAMESPACE'],
            'listener-test'          => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
            'views/index'            => ['LOWER_NAME'],
            'views/index-admin'      => ['LOWER_NAME', 'STUDLY_NAME'],
            'views/frontend'         => ['STUDLY_NAME'],
            'views/admin'            => ['STUDLY_NAME'],
            'controller'             => ['MODULE_NAMESPACE', 'STUDLY_NAME', 'CLASS_NAMESPACE', 'LOWER_NAME'],
            'controller-admin'       => ['MODULE_NAMESPACE', 'STUDLY_NAME', 'CLASS_NAMESPACE', 'LOWER_NAME'],
            'controller-api'         => ['MODULE_NAMESPACE', 'STUDLY_NAME', 'CLASS_NAMESPACE', 'LOWER_NAME'],
            'config'                 => ['STUDLY_NAME'],
            'composer'               => [
                'LOWER_NAME',
                'STUDLY_NAME',
                'VENDOR',
                'AUTHOR_NAME',
                'AUTHOR_EMAIL',
                'MODULE_NAMESPACE',
            ],
        ],
        'gitkeep' => false,
    ],
    'paths' => [
        'modules'   => base_path('modules'),
        'assets'    => public_path('modules'),
        'migration' => base_path('database/migrations'),
        'generator' => [
            'config'           => ['path' => 'Config', 'generate' => true],
            'command'          => ['path' => 'Console', 'generate' => true],
            'migration'        => ['path' => 'Database/migrations', 'generate' => true],
            'seeds'            => ['path' => 'Database/seeds', 'generate' => true],
            'factory'          => ['path' => 'Database/factories', 'generate' => true],
            'model'            => ['path' => 'Models', 'generate' => true],
            'controller'       => ['path' => 'Http/Controllers', 'generate' => true],
            'controller-admin' => ['path' => 'Http/Controllers/Admin', 'generate' => true],
            'controller-api'   => ['path' => 'Http/Controllers/Api', 'generate' => true],
            'filter'           => ['path' => 'Http/Middleware', 'generate' => true],
            'request'          => ['path' => 'Http/Requests', 'generate' => true],
            'routes'           => ['path' => 'Http/Routes', 'generate' => true],
            'provider'         => ['path' => 'Providers', 'generate' => true],
            'assets'           => ['path' => 'Resources/assets', 'generate' => true],
            'lang'             => ['path' => 'Resources/lang', 'generate' => true],
            'views'            => ['path' => 'Resources/views', 'generate' => true],
            'test'             => ['path' => 'tests', 'generate' => true],
            'repository'       => ['path' => 'Repositories', 'generate' => false],
            'event'            => ['path' => 'Events', 'generate' => false],
            'listener'         => ['path' => 'Listeners', 'generate' => true],
            'policies'         => ['path' => 'Policies', 'generate' => false],
            'rules'            => ['path' => 'Rules', 'generate' => false],
            'jobs'             => ['path' => 'Jobs', 'generate' => false],
            'emails'           => ['path' => 'Resources/Emails', 'generate' => false],
            'notifications'    => ['path' => 'Notifications', 'generate' => false],
            'resource'         => ['path' => 'Models/Transformers', 'generate' => false],
        ],
    ],
    /*
    |--------------------------------------------------------------------------
    | Scan Path
    |--------------------------------------------------------------------------
    |
    | Here you define which folder will be scanned. By default will scan vendor
    | directory. This is useful if you host the package in packagist website.
    |
    */

    'scan' => [
        'enabled' => false,
        'paths'   => [
            base_path('vendor/*/*'),
            base_path('modules/*'),
        ],
    ],
    /*
    |--------------------------------------------------------------------------
    | Composer File Template
    |--------------------------------------------------------------------------
    |
    | Here is the config for composer.json file, generated by this package
    |
    */

    'composer' => [
        'vendor' => '',
        'author' => [
            'name'  => '',
            'email' => '',
        ],
    ],
    /*
    |--------------------------------------------------------------------------
    | Caching
    |--------------------------------------------------------------------------
    |
    | Here is the config for setting up caching feature.
    |
    */
    'cache' => [
        'enabled'  => true,
        'key'      => 'phpvms-modules',
        'lifetime' => 10,
    ],
    /*
    |--------------------------------------------------------------------------
    | Choose what laravel-modules will register as custom namespaces.
    | Setting one to false will require you to register that part
    | in your own Service Provider class.
    |--------------------------------------------------------------------------
    */
    'register' => [
        'translations' => true,
    ],

    'activator'  => 'file',
    'activators' => [
        'file' => [
            'class'          => FileActivator::class,
            'statuses-file'  => config_path('modules_statuses.json'),
            'cache-key'      => 'activator.installed',
            'cache-lifetime' => 604800,
        ],
    ],
];

I'm trying to debug with some people who are running into issues with generating modules; it looks like the service provider (TestModuleServiceProvider in this case wasn't generated). And it looks also like the caches (config, routes) didn't get cleared (I can't remember if this was supposed to be the case). It could also be that I'm missing some configuration or something in the upgrade to Laravel 7, but I haven't seen anything specific). Thanks!

@nWidart
Copy link
Owner

nWidart commented May 22, 2020

Hi, did you add the autoloading of modules in the composer.json of your project (you can find out how in the readme)?

@nabeelio
Copy link
Author

Hey, yes, that's there. It was fine with Laravel 6. Here's the appropriate section:

https://github.com/nabeelio/phpvms/blob/dev/composer.json#L85

@nabeelio
Copy link
Author

I updated the main post with some more information

@nWidart
Copy link
Owner

nWidart commented May 22, 2020

Hm that's weird.
First thing I would do is to publish the config again using the --force flag, clear all caches, run composer dump-autoload, and make sure you ran the migrate command.

@nabeelio
Copy link
Author

I get the same problem. The error is happening during the module generation. It's not outputting the full stacktrace, I'm trying to see what it's attempting to do

@nabeelio
Copy link
Author

Here's the full stacktrace. Looks like it's failing to create the provider, though the module.json, etc is all there

Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/module.json
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Routes/web.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Routes/api.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Routes/admin.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Providers/AppServiceProvider.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Providers/EventServiceProvider.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Providers/RouteServiceProvider.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Resources/views/index.blade.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Resources/views/admin/index.blade.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Resources/views/layouts/frontend.blade.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Resources/views/layouts/admin.blade.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Listeners/TestEventListener.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Controllers/Frontend/IndexController.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Controllers/Api/ApiController.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Http/Controllers/Admin/AdminController.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/Config/config.php
Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/composer.json
[2020-05-22T21:45:46.269212+00:00] dev.ERROR: Module [TestModule] does not exist! {"exception":"[object] (Nwidart\\Modules\\Exceptions\\ModuleNotFoundException(code: 0): Module [TestModule] does not exist! at /Users/nabeelshahzad/dev/nabeelio/phpvms/vendor/nwidart/laravel-modules/src/FileRepository.php:396)"} []

   Nwidart\Modules\Exceptions\ModuleNotFoundException

  Module [TestModule] does not exist!

  at vendor/nwidart/laravel-modules/src/FileRepository.php:396
    392|         if ($module !== null) {
    393|             return $module;
    394|         }
    395|
  > 396|         throw new ModuleNotFoundException("Module [{$name}] does not exist!");
    397|     }
    398|
    399|     /**
    400|      * Get all modules as laravel collection instance.

  1   vendor/nwidart/laravel-modules/src/Traits/ModuleCommandTrait.php:16
      Nwidart\Modules\FileRepository::findOrFail("TestModule")

  2   vendor/nwidart/laravel-modules/src/Commands/ProviderMakeCommand.php:101
      Nwidart\Modules\Commands\ProviderMakeCommand::getModuleName()

  3   vendor/nwidart/laravel-modules/src/Commands/GeneratorCommand.php:37
      Nwidart\Modules\Commands\ProviderMakeCommand::getDestinationFilePath()

  4   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
      Nwidart\Modules\Commands\GeneratorCommand::handle()

  5   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
      call_user_func_array([])

  6   vendor/laravel/framework/src/Illuminate/Container/Util.php:36
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  7   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:91
      Illuminate\Container\Util::unwrapIfClosure(Object(Closure))

  8   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
      Illuminate\Container\BoundMethod::callBoundMethod(Object(application), Object(Closure))

  9   vendor/laravel/framework/src/Illuminate/Container/Container.php:592
      Illuminate\Container\BoundMethod::call(Object(application), [])

  10  vendor/laravel/framework/src/Illuminate/Console/Command.php:134
      Illuminate\Container\Container::call()

  11  vendor/symfony/console/Command/Command.php:255
      Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))

  12  vendor/laravel/framework/src/Illuminate/Console/Command.php:121
      Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))

  13  vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php:56
      Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))

  14  vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php:28
      Illuminate\Console\Command::runCommand("module:make-provider", ["TestModuleServiceProvider", "TestModule", "module:make-provider"], Object(Illuminate\Console\OutputStyle))

  15  vendor/nwidart/laravel-modules/src/Generators/ModuleGenerator.php:384
      Illuminate\Console\Command::call("module:make-provider", ["TestModuleServiceProvider", "TestModule"])

  16  vendor/nwidart/laravel-modules/src/Generators/ModuleGenerator.php:308
      Nwidart\Modules\Generators\ModuleGenerator::generateResources()

  17  vendor/nwidart/laravel-modules/src/Commands/ModuleMakeCommand.php:44
      Nwidart\Modules\Generators\ModuleGenerator::generate()

  18  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
      Nwidart\Modules\Commands\ModuleMakeCommand::handle()

  19  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
      call_user_func_array([])

  20  vendor/laravel/framework/src/Illuminate/Container/Util.php:36
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  21  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:91
      Illuminate\Container\Util::unwrapIfClosure(Object(Closure))

  22  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
      Illuminate\Container\BoundMethod::callBoundMethod(Object(application), Object(Closure))

  23  vendor/laravel/framework/src/Illuminate/Container/Container.php:592
      Illuminate\Container\BoundMethod::call(Object(application), [])

  24  vendor/laravel/framework/src/Illuminate/Console/Command.php:134
      Illuminate\Container\Container::call()

  25  vendor/symfony/console/Command/Command.php:255
      Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  26  vendor/laravel/framework/src/Illuminate/Console/Command.php:121
      Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  27  vendor/symfony/console/Application.php:912
      Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  28  vendor/symfony/console/Application.php:264
      Symfony\Component\Console\Application::doRunCommand(Object(Nwidart\Modules\Commands\ModuleMakeCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  29  vendor/symfony/console/Application.php:140
      Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  30  vendor/laravel/framework/src/Illuminate/Console/Application.php:93
      Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  31  vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129
      Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  32  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

@nabeelio
Copy link
Author

nabeelio commented May 22, 2020

The generated controller name isn't also being substituted anymore:

/**
 * Class $CLASS$
 * @package 
 */
class $CLASS$ extends Controller
{

Whereas before it took the name of the created module.

@nabeelio
Copy link
Author

nabeelio commented May 25, 2020

Ok, so I removed all of the files to generate from the config, it was just confusing me. So it should generate automatically only the module.json, which it does, and then the main service provider (which fails).

$ php artisan -v module:make TestModule --force

Created : /Users/nabeelshahzad/dev/nabeelio/phpvms/modules/TestModule/module.json
[2020-05-25T03:00:08.520781+00:00] dev.ERROR: Module [TestModule] does not exist! {"exception":"[object] (Nwidart\\Modules\\Exceptions\\ModuleNotFoundException(code: 0): Module [TestModule] does not exist! at /Users/nabeelshahzad/dev/nabeelio/phpvms/vendor/nwidart/laravel-modules/src/FileRepository.php:396)"} []

   Nwidart\Modules\Exceptions\ModuleNotFoundException

  Module [TestModule] does not exist!

  at vendor/nwidart/laravel-modules/src/FileRepository.php:396
    392|         if ($module !== null) {
    393|             return $module;
    394|         }
    395|
  > 396|         throw new ModuleNotFoundException("Module [{$name}] does not exist!");
    397|     }
    398|
    399|     /**
    400|      * Get all modules as laravel collection instance.

  1   vendor/nwidart/laravel-modules/src/Traits/ModuleCommandTrait.php:16
      Nwidart\Modules\FileRepository::findOrFail("TestModule")

  2   vendor/nwidart/laravel-modules/src/Commands/ProviderMakeCommand.php:101
      Nwidart\Modules\Commands\ProviderMakeCommand::getModuleName()

  3   vendor/nwidart/laravel-modules/src/Commands/GeneratorCommand.php:37
      Nwidart\Modules\Commands\ProviderMakeCommand::getDestinationFilePath()

  4   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
      Nwidart\Modules\Commands\GeneratorCommand::handle()

  5   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
      call_user_func_array([])

  6   vendor/laravel/framework/src/Illuminate/Container/Util.php:36
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  7   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:91
      Illuminate\Container\Util::unwrapIfClosure(Object(Closure))

  8   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
      Illuminate\Container\BoundMethod::callBoundMethod(Object(application), Object(Closure))

  9   vendor/laravel/framework/src/Illuminate/Container/Container.php:592
      Illuminate\Container\BoundMethod::call(Object(application), [])

  10  vendor/laravel/framework/src/Illuminate/Console/Command.php:134
      Illuminate\Container\Container::call()

  11  vendor/symfony/console/Command/Command.php:255
      Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))

  12  vendor/laravel/framework/src/Illuminate/Console/Command.php:121
      Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))

  13  vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php:56
      Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))

  14  vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php:28
      Illuminate\Console\Command::runCommand("module:make-provider", ["TestModuleServiceProvider", "TestModule", "module:make-provider"], Object(Illuminate\Console\OutputStyle))

  15  vendor/nwidart/laravel-modules/src/Generators/ModuleGenerator.php:384
      Illuminate\Console\Command::call("module:make-provider", ["TestModuleServiceProvider", "TestModule"])

  16  vendor/nwidart/laravel-modules/src/Generators/ModuleGenerator.php:308
      Nwidart\Modules\Generators\ModuleGenerator::generateResources()

  17  vendor/nwidart/laravel-modules/src/Commands/ModuleMakeCommand.php:44
      Nwidart\Modules\Generators\ModuleGenerator::generate()

  18  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
      Nwidart\Modules\Commands\ModuleMakeCommand::handle()

  19  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
      call_user_func_array([])

  20  vendor/laravel/framework/src/Illuminate/Container/Util.php:36
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  21  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:91
      Illuminate\Container\Util::unwrapIfClosure(Object(Closure))

  22  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
      Illuminate\Container\BoundMethod::callBoundMethod(Object(application), Object(Closure))

  23  vendor/laravel/framework/src/Illuminate/Container/Container.php:592
      Illuminate\Container\BoundMethod::call(Object(application), [])

  24  vendor/laravel/framework/src/Illuminate/Console/Command.php:134
      Illuminate\Container\Container::call()

  25  vendor/symfony/console/Command/Command.php:255
      Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  26  vendor/laravel/framework/src/Illuminate/Console/Command.php:121
      Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  27  vendor/symfony/console/Application.php:912
      Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  28  vendor/symfony/console/Application.php:264
      Symfony\Component\Console\Application::doRunCommand(Object(Nwidart\Modules\Commands\ModuleMakeCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  29  vendor/symfony/console/Application.php:140
      Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  30  vendor/laravel/framework/src/Illuminate/Console/Application.php:93
      Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  31  vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129
      Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  32  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

$ tree modules/TestModule
modules/TestModule
├── Config
├── Console
├── Database
│   ├── factories
│   ├── migrations
│   └── seeds
├── Http
│   ├── Controllers
│   │   ├── Admin
│   │   └── Api
│   ├── Middleware
│   ├── Requests
│   └── Routes
├── Listeners
├── Models
├── Providers
├── Resources
│   ├── assets
│   ├── lang
│   └── views
├── module.json
└── tests

But I'm not sure why it's not finding it even after the module.json is generated. It shouldn't be checking any cache at this point:

image

@nWidart
Copy link
Owner

nWidart commented Jul 2, 2020

I'm not sure what's going on here. Did you customise the installation?
Can you reproduce this on an empty project and upload it somewhere?

@nabeelio
Copy link
Author

nabeelio commented Jul 3, 2020

The only thing I customized was the templates. I will try to get a L7 install together with a default but yeah I'm not sure why this is happening either. It just looks like after it generates the module.json and composer.json files, it doesn't refresh its own cache of which modules are installed. I think there might be a conflict somewhere with the caching and that configuration

@williamqian
Copy link

The only thing I customized was the templates. I will try to get a L7 install together with a default but yeah I'm not sure why this is happening either. It just looks like after it generates the module.json and composer.json files, it doesn't refresh its own cache of which modules are installed. I think there might be a conflict somewhere with the caching and that configuration

I met the same problem like yours

@williamqian
Copy link

The only thing I customized was the templates. I will try to get a L7 install together with a default but yeah I'm not sure why this is happening either. It just looks like after it generates the module.json and composer.json files, it doesn't refresh its own cache of which modules are installed. I think there might be a conflict somewhere with the caching and that configuration

have you resolved this problem?

@nabeelio
Copy link
Author

I haven't, still waiting for a fix. I haven't had the chance to dupe it on a fresh install. Have you?

@williamqian
Copy link

I haven't, still waiting for a fix. I haven't had the chance to dupe it on a fresh install. Have you?

Not yet,I'm waiting too

@nWidart
Copy link
Owner

nWidart commented Jul 30, 2020

As I haven't been able to reproduce this at all, maybe you guys could look for the problem & a possible fix? 😅

@williamqian
Copy link

As I haven't been able to reproduce this at all, maybe you guys could look for the problem & a possible fix? 😅

I‘d like to,but limited to my level...

@nabeelio
Copy link
Author

@williamqian have you modified any templates?

@nWidart I have a suspicion it's with the caching and scanning after a module is generated but I'm not familiar enough with it

@williamqian
Copy link

williamqian commented Jul 30, 2020

@williamqian have you modified any templates?

@nWidart I have a suspicion it's with the caching and scanning after a module is generated but I'm not familiar enough with it

Yes, I just copy all the .stubs to another path,and set enabled to true,my laravel framework's version is 7.21.0。

'stubs' => [
        'enabled' => true,
        'path' => resource_path('stubs'),
]

@nabeelio
Copy link
Author

@williamqian thanks... How about in a fresh project? @nWidart that seems to be a commonality, have you tried testing with that?

I will try to dupe in a fresh project over the weekend

@williamqian
Copy link

williamqian commented Jul 30, 2020

@williamqian thanks... How about in a fresh project? @nWidart that seems to be a commonality, have you tried testing with that?

I will try to dupe in a fresh project over the weekend

in fresh project,it works well until I set cache.enabled=true in config/modules.php,so I set my project's cache.enabled=false,now it works well...

@nabeelio
Copy link
Author

Interesting, I'll have to try that. That seems like a bug for sure, I leave the cache disabled because a user can add modules at any time.

@nWidart does that help?

nabeelio added a commit to nabeelio/phpvms that referenced this issue Aug 8, 2020
Disable/lower the cache time as found as a workaround in nWidart/laravel-modules#995
nabeelio added a commit to nabeelio/phpvms that referenced this issue Aug 12, 2020
Disable/lower the cache time as found as a workaround in nWidart/laravel-modules#995
nabeelio added a commit to nabeelio/phpvms that referenced this issue Sep 20, 2020
* Update module generation #714

* Fix method signatures

* Fix paths within stubs, use single provider.stub file

* Add separate index controller

* Update module generation #714

* Fix method signatures

* Fix paths within stubs, use single provider.stub file

* Update module generation

Disable/lower the cache time as found as a workaround in nWidart/laravel-modules#995

* Update editorconfig for line endings

* Formatting

* Formatting
@nWidart nWidart closed this as completed Oct 3, 2020
@nabeelio
Copy link
Author

nabeelio commented Oct 3, 2020

Hi, why'd this get closed? We outlined the bug above... if cache is enabled then there's a problem

@nWidart
Copy link
Owner

nWidart commented Oct 3, 2020

Hi,

With laravel 8 I cleaned up the issues on the repository.
I tried to reproduce this again and was unable to.

@nabeelio
Copy link
Author

nabeelio commented Oct 3, 2020

Ok, great, thanks, just didn't see a commit linked to this or mentioned in the change log. Is it fixed only for Laravel 8 going forward, or the next release of this? Is there a migration guide on if anything has changed? I'm trying to understand the impact of something like #996

@nWidart
Copy link
Owner

nWidart commented Oct 3, 2020

Hi,

You could try on laravel 8 to see if you still have the issue, hopefully not.

Regarding #996, there is no action required. That PR was also merged & tagged before this release, so you likely already have it.

@nabeelio
Copy link
Author

nabeelio commented Oct 3, 2020

I haven't migrated to 8 yet, that might be a larger task... for L7, I'm guessing the 8x version of this will be fine

@nWidart
Copy link
Owner

nWidart commented Oct 3, 2020

Ah yes I understand. Please let me know if the issue persists in the future!

@hsul4n
Copy link

hsul4n commented Oct 24, 2022

I was facing same issue because of renaming module folder without updating module.json file.

So make sure that module.json file has correct module names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants