abduljakul-salsalani's avatar

How to hide laravel-debugbar in a specific view.

I just want to hide laravel debugbar when I'm on a specific route or view. or hide them when I'm on production mode.

0 likes
2 replies
Borisu's avatar

You have to do this in the AppServiceProvider. There in the register method you can check if the environment is production and hide it.

if ($this->app->isLocal()) {
    $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}

Similarly you can check if you're on a specific view:

if (! Route::is('some.route', 'another.route')) {
    $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}

I'll leave the optimization to you tho ;)

Snapey's avatar

You should have it in the "require-dev" section of composer so that it is not installed on production builds.

Please or to participate in this conversation.