How to safely remove Laravel Debugbar

Remove Laravel Debugbar

- If you want to totally remove the package, then do these steps:

  1. $ composer remove vendor/barryvdh/laravel-debugbar
  2. $ composer update

Disable Laravel Debugbar


Option 1: Via Env File

- If you want disable the package, without it getting tracked by Git:

  1. Navigate to your .env file
  2. And put DEBUGBAR_ENABLED = FALSE


Option 2: Via AppServiceProvider

- From @Ohgodwhy's answer

- FYI: This will be tracked by Git. - @Salam

  1. Navigate to app/Providers/AppServiceProvider.php
  2. Put this code \Debugbar::disable();

    class AppServiceProvider extends ServiceProvider
    {
        public function boot()
        {
            \Debugbar::disable();
        }
    }
    

Best option:

Add DEBUGBAR_ENABLED=false to your .env

This has some advantages over Abdulla Nilam's answer:

  • Debugbar is totally disabled

  • You can keep APP_DEBUG=true, hence still keep error details for local development

  • It is not tracked by git


To completely disable the debugger

In .env

APP_DEBUG=false # No error reporting at all

Disable the debugger but still wants to receive Errors (**Recommended way)

In .env

DEBUGBAR_ENABLED=false # deguger is disabled but error reporting works

FYI: Once you changed the values on .env and it didn't reflex, clear the config using php artisan config:clear or php artisan optimize:clear


Useful Links

  1. Errors & Logging Laravel Docs 9.x
  2. Laravel Debugbar

Enabling/Disabling on run time.

You can enable or disable the debugbar during run time.

Add this into your .env file:

DEBUGBAR_ENABLED = FALSE

In runtime:

\Debugbar::enable();
\Debugbar::disable();

Or remove everything

composer remove barryvdh/laravel-debugbar