php - Class "ModulesBeritaProvidersBeritaServiceProvider" not found - Stack Overflow

admin2025-05-02  0

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 "Modules\Berita\Providers\BeritaServiceProvider" not found

  at vendor\laravel\framework\src\Illuminate\Foundation\Application.php:935
    931▕      * @return \Illuminate\Support\ServiceProvider
    932▕      */
    933▕     public function resolveProvider($provider)
    934▕     {
  ➜ 935▕         return new $provider($this);
    936▕     }
    937▕
    938▕     /**
    939▕      * Mark the given provider as registered.

  1   vendor\laravel\framework\src\Illuminate\Foundation\Application.php:867
      Illuminate\Foundation\Application::resolveProvider()

  2   vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php:75
      Illuminate\Foundation\Application::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.

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 "Modules\Berita\Providers\BeritaServiceProvider" not found

  at vendor\laravel\framework\src\Illuminate\Foundation\Application.php:935
    931▕      * @return \Illuminate\Support\ServiceProvider
    932▕      */
    933▕     public function resolveProvider($provider)
    934▕     {
  ➜ 935▕         return new $provider($this);
    936▕     }
    937▕
    938▕     /**
    939▕      * Mark the given provider as registered.

  1   vendor\laravel\framework\src\Illuminate\Foundation\Application.php:867
      Illuminate\Foundation\Application::resolveProvider()

  2   vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php:75
      Illuminate\Foundation\Application::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.

Share Improve this question asked Jan 2 at 2:06 Bachtiar Dwi JuliantoBachtiar Dwi Julianto 91 bronze badge 3
  • 3 Show the composer.json file. Looks like you have not installed the specified package. Did you run the composer install command? – Raghavendra N Commented Jan 2 at 3:46
  • Does your file have the correct path, as defined in your composer.json? note that on most systems, the path is case sensitive. – Gert B. Commented Jan 2 at 11:06
  • Are you sure you're not accidentally registering that service provider in both branches? – IGP Commented Jan 2 at 13:00
Add a comment  | 

2 Answers 2

Reset to default 0

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 Modules\Berita\Providers\BeritaServiceProvider::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

转载请注明原文地址:http://anycun.com/QandA/1746136776a92081.html