Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable laravel debugbar dynamically #1384

Open
michaltobiaszfpwd opened this issue Feb 3, 2023 · 5 comments
Open

Enable laravel debugbar dynamically #1384

michaltobiaszfpwd opened this issue Feb 3, 2023 · 5 comments

Comments

@michaltobiaszfpwd
Copy link

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?

@BataBoom
Copy link

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

@irvingzamora
Copy link

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

@vatsake
Copy link

vatsake commented Jun 8, 2023

Any updates on this?

@thearyanahmed
Copy link

thearyanahmed commented Mar 5, 2024

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

@erikn69
Copy link
Contributor

erikn69 commented Mar 5, 2024

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,
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants