laravel-debugbar
laravel-debugbar copied to clipboard
Enable laravel debugbar dynamically
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?
Having same issue here. I've tried custom Middleware and AppServiceProvider methods. No dice yet.
Do you want to enable the debugbar only on certain routes?
Any updates on this?
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
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,
];