@inquisitive according to the latest debugbar version https://github.com/barryvdh/laravel-debugbar/blob/master/config/debugbar.php you can use DEBUGBAR_ENABLED istead of APP_DEBUG (set APP_DEBUG to false, but DEBUGBAR_ENABLED to true). After that try to apply your conditions in middleware
Jan 4, 2023
6
Level 9
Best way to enable laravel debugbar on for superadmin or for certain ip
For now, I have created a middleware and added it into the 'web' group in kernel. MY DebugBarMiddleware have:
{
$debugBarEnabledIps = DebugBarWhitelistedIpAddress::where('updated_at','>=', Carbon::now()->subDays(7))
->pluck('ip_address')->toArray();
if (auth()->check() && in_array($request->ip(), $debugBarEnabledIps)) {
app('debugbar')->enable();
config('app.debug', true);
}else{
config('app.debug', false);
app('debugbar')->disable();
}
return $next($request);
}
The above code works fine only, when I set APP_DEBUG to true on env. And, with that, any of the other errors are also becoming visible. With APP_DEBUG = false, it used to show only 500 server error.
Is there any better approach to deal with it?
Please or to participate in this conversation.