-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
Description
Provider not found error in Laravel 12 with nwidart/laravel-modules
Environment
- PHP Version: 8.4.13
- Laravel Version: ^12
- Package Version: nwidart/laravel-modules ^12.0
Description
After following the setup steps for nwidart/laravel-modules, I'm still encountering a "provider not found" error when trying to use modules in Laravel 12.
getting error this again and again
php artisan
Error
Class "App\Modules\Platform\Providers\PlatformServiceProvider" not found
at vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:205
201▕ * @return \Illuminate\Support\ServiceProvider
202▕ */
203▕ public function createProvider($provider)
204▕ {
➜ 205▕ return new $provider($this->app);
206▕ }
207▕ }
208▕
+12 vendor frames
13 artisan:16
Configuration
Root composer.json:
{
"autoload": {
"psr-4": {
"App\\": "app/",
"App\\Modules\\": "app/Modules",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"extra": {
"laravel": {
"dont-discover": []
},
"merge-plugin": {
"include": [
"app/Modules/*/composer.json"
]
}
}
}app/Modules/Platform/composer.json:
{
//...
"autoload": {
"psr-4": {
"App\\Modules\\Platform\\": "app/",
"App\\Modules\\Platform\\Database\\Factories\\": "database/factories/",
"App\\Modules\\Platform\\Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Modules\\Platform\\Tests\\": "tests/"
}
}
}
config/modules.php:
'namespace' => 'App\Modules',
'paths' => [
'modules' => base_path('app/Modules'),
],Steps to Reproduce
- Install package:
composer require nwidart/laravel-modules - Publish config:
php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider" - Add
"App\\Modules\\": "app/Modules"to rootcomposer.jsonautoload section - Run
composer dump-autoload - Create module:
php artisan module:make Platform
Directory Structure
├── app
│ ├── Modules
│ │ └── Platform
│ │ ├── app
│ │ │ ├── Http
│ │ │ │ └── Controllers
│ │ │ └── Providers
│ │ ├── config
│ │ ├── database
│ │ │ ├── factories
│ │ │ ├── migrations
│ │ │ └── seeders
│ │ ├── resources
│ │ │ ├── assets
│ │ │ │ ├── js
│ │ │ │ └── sass
│ │ │ └── views
│ │ ├── routes
│ │ └── tests
│ │ ├── Feature
│ │ └── Unit
│ └── Providers
Expected Behavior
Modules should be discovered and loaded without errors.
Actual Behavior
Getting "provider not found" error.
Additional Context
- All configuration appears correct
composer dump-autoloadhas been run- Module structure is generated correctly by the package
Question
What additional steps or configuration am I missing to resolve this "provider not found" error in Laravel 12?