laravel-debugbar icon indicating copy to clipboard operation
laravel-debugbar copied to clipboard

Enable laravel debugbar dynamically

Open michaltobiaszfpwd opened this issue 2 years ago • 5 comments
trafficstars

Is there any way to disable the debugbar by default and enable it dynamically in the middleware?

When in AppServiceProvider boot I add Debugbar::disable(); and then in the middleware in the condition I add Debugbar::enable(); it does not work.

Replacing config('debugbar.enabled') doesn't work either.

Is it possible to do?

michaltobiaszfpwd avatar Feb 03 '23 11:02 michaltobiaszfpwd

Having same issue here. I've tried custom Middleware and AppServiceProvider methods. No dice yet.

BataBoom avatar Apr 15 '23 12:04 BataBoom

Do you want to enable the debugbar only on certain routes?

irvingzamora avatar Apr 19 '23 15:04 irvingzamora

Any updates on this?

vatsake avatar Jun 08 '23 05:06 vatsake

You can enable debugbar only on certain routes by passing an array of URIs.

https://github.com/barryvdh/laravel-debugbar/blob/master/config/debugbar.php#L13-L22

Also, maybe you can have a middleware similar to InjectDebugbar. Maybe extend from this middleware and override the handle method to forcefully boot the debugbar?

https://github.com/barryvdh/laravel-debugbar/blob/master/src/Middleware/InjectDebugbar.php

thearyanahmed avatar Mar 05 '24 21:03 thearyanahmed

When in AppServiceProvider boot I add Debugbar::disable(); and then in the middleware in the condition I add Debugbar::enable(); it does not work.

I do the same, and works But i add on app/Http/kernel.php

protected $middlewarePriority = [
    ///
    \App\Http\Middleware\DebugbarEnabler::class, // my middleware
    \Barryvdh\Debugbar\Middleware\InjectDebugbar::class,
];

erikn69 avatar Mar 05 '24 21:03 erikn69