Halo, jika tulisan ini membantu Anda, Anda dapat mengekspresikan rasa terima kasih melalui saweria .

Hello, if you find this article helpful, you can express your gratitude through saweria .



Problem

When running php composer install --no-dev --prefer-source --no-interaction --no-progress --optimize-autoloader to install packages in a production setup, an error occurs: class 'Barryvdh\Debugbar\ServiceProvider' not found.

Even though the package “barryvdh/laravel-debugbar” is only required in development (it is listed only in require-dev), this error won’t disappear, and it makes you think “what’s wrong with my setup?”

Class Not Found When Using composer install --no-dev, Even When It Is Only Listed In ‘require-dev’ In package.json

Class Not Found When Using composer install --no-dev, Even When It Is Only Listed In ‘require-dev’ In package.json


How To Fix It

  1. Remove the “barryvdh/laravel-debugbar” package: composer remove barryvdh/laravel-debugbar.

  2. Run php artisan config:cache to clear all debugbar configurations.

  3. Remove Barryvdh\Debugbar\ServiceProvider from config/app.php. (For Laravel 11 or newer, add the ServiceProvider in bootstrap/providers.php. For Laravel 10 or older, add the ServiceProvider in config/app.php.)

  4. Re-add the “barryvdh/laravel-debugbar” package as a development requirement: composer require barryvdh/laravel-debugbar --dev.

References:

  1. Github barryvdh/laravel-debugbar

  2. Github barryvdh/laravel-debugbar - issues 480