I’m having trouble switching branches from the news feature to the complaints feature, but why does my Laravel always access the news module when actually the module is in another branch? What’s the solution ?
I have tried to run the composer dump-autoload
command but it errors with the same message.
Error
Class "ModulesBeritaProvidersBeritaServiceProvider" not found at vendorlaravelframeworksrcIlluminateFoundationApplication.php:935 931▕ * @return IlluminateSupportServiceProvider 932▕ */ 933▕ public function resolveProvider($provider) 934▕ { ➜ 935▕ return new $provider($this); 936▕ } 937▕ 938▕ /** 939▕ * Mark the given provider as registered. 1 vendorlaravelframeworksrcIlluminateFoundationApplication.php:867 IlluminateFoundationApplication::resolveProvider() 2 vendorlaravelframeworksrcIlluminateFoundationProviderRepository.php:75 IlluminateFoundationApplication::register()
I have tried to run the command composer dump-autoload
, php artisan config:clear
, php artisan cache:clear
but it errors with the same message.
2
Answers
When We are using
nWidart/laravel-modules
In our Modules All the providers in App Directory and we are callingModulesBeritaProvidersBeritaServiceProvider
So to provide namespace in module’scomposer.json
it provides path in autoloadPlease Include above to your
composer.json
and runcomposer dump-autoload
Ref from link :
https://github.com/nWidart/laravel-modules/issues/4
The error happens because Laravel is still trying to load the News (Berita) module even though you’ve switched branches. Here’s how to fix it:
Check config/app.php and remove the News provider if it’s there:
// Remove this if you find it
ModulesBeritaProvidersBeritaServiceProvider::class,
If you’re using the Laravel-modules package, update modules_statuses.json:
Json -> {
"Berita": false
}
Run these commands in order:
php artisan config:clear
php artisan cache:clear
php artisan route:clear
composer dump-autoload
If that doesn’t work, try cleaning your Git state:
git clean -fd
git reset –hard
Still, having issues? Delete vendor and reinstall:
rm -of vendor/
rm composer.lock
composer install
Hope this helps! Let me know if you need anything else 👍