After installing the package nwidart/laravel-modules and configuring it with the commands provided in the package documentation, I encounter the following error after creating a simple module:
Class “ModulesPhpMyAdminProvidersPhpMyAdminServiceProvider” not
found
Here are the changes made to the composer.json file to use the module:
{
"$schema": "https://getcomposer.org/schema.json",
"name": "laravel/laravel",
//........................
"require": {
"php": "^8.2",
//........................
"nwidart/laravel-modules": "^11.1"
},
"require-dev": {
//........................
},
"autoload": {
"psr-4": {
"Modules\": "Modules/",
//........................
}
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
//........................
"extra": {
"laravel": {
"dont-discover": [
],
"merge-plugin": {
"include": [
"Modules/*/composer.json"
]
}
}
},
//........................
"minimum-stability": "dev",
"prefer-stable": true
}
After running the command composer dump-autoload, I expected to access the route within the phpmyadmin module using the address localhost:8000/phpmyadmin:
php
Route::get('phpmyadmin', function () {
dd('test');
})->name('phpmyadmin');
What I’ve noticed is that in the file bootstrap/cache/module.php, the service provider for the module I created is defined as follows:
<?php return array (
'providers' =>
array (
0 => 'Modules\PhpMyAdmin\Providers\PhpMyAdminServiceProvider',
),
'eager' =>
array (
0 => 'Modules\PhpMyAdmin\Providers\PhpMyAdminServiceProvider',
),
'deferred' =>
array (
),
);
When I remove these service providers, the error goes away, but the issue of accessing the page still persists, resulting in a 404 error, and this route is not visible in the Laravel routes list when I run:
php artisan route:list
Feel free to post this on Stack Overflow for assistance!