0

I ran into a weird problem. I'm using Nwidart Laravel Modules package. I have got many modules and everything works as expected: service providers register routes for each module etc. But suddenly, I lost contact with one module - all my endpoints are not registered - I see only 404 error page. At first, I checked php artisan route:list - missing API routes are there. Then I checked php artisan module:list - the missing module is loaded and enabled. Next step: check module.json file in module directory: looks ok, module service provider exists in providers array. I do some debugging, and I found that this provider is not loaded anymore. I am trying to figure out what's wrong here, but I'm out of ideas.

Update:

After I run php artisan route:cache command, missing routes are now available.

Daniel
  • 2,621
  • 2
  • 18
  • 34
  • Make sure that module's routes are being registered correctly in the service provider's `boot()` method. – Sachin Dec 17 '22 at 18:56
  • They are registered in`register` method in the module service provider: `$this->app->register(RouteServiceProvider::class);`. This provider extends native `Illuminate\Foundation\Support\Providers\RouteServiceProvider` and has `map` method. The big issue here is that I compared this provider with other modules, and I did not found any differences. – Daniel Dec 17 '22 at 22:38

1 Answers1

0

I finally figured it out. I will describe my case here; I hope it will help someone in the future. Two things were responsible for my issue: bootstrap/cache and DeferrableProvider. At some point, I used DeferrableProvider for my module but I even didn't know it that is not working, because configuration for this module was cached as manifest file inside bootstrap/cache directory (XYZ_module.php). The valid configuration was always loaded until I've done composer update and cleared caches. Since then, the wrong configuration is preserved in cache causing module fault. I had to remove DeferrableProvider interface from provider class to fix it ($defer and provides method also). The next step is to clear the cache/config etc. and I'm back to business!

Update: clearing cache/config may not remove modules manifest files from bootstrap/cache directory. In this case, files need to be deleted manually.

Daniel
  • 2,621
  • 2
  • 18
  • 34