I've been using debugbar in the production environment behind a cookie and an auth check for quite some time.
However after upgrading to v4 I noticed it no longer works.
I tried to enable it by setting config debugbar.enabled to true, yet that didn't help.
I found out that early return in ServiceProvider->boot() ignores all the config options and is fully dependent on APP_DEBUG and APP_ENV.
|
// Eearly return if debugbar can not enabled |
|
if (!LaravelDebugbar::canBeEnabled()) { |
|
return; |
|
} |
Another place that ignores the config the same way is LaravelDebugbar->isEnabled()
|
if (!static::canBeEnabled()) { |
|
$this->enabled = false; |
|
} else { |
As a temporary workaround I applied a composer patch for both of those places to check the value of config('debugbar.enabled').
That's a dirty fix, but it's good enough for my purposes, and from testing I see only users passing the auth gate have access. Debugbar also turns off early in the stack if someone doesn't pass the gate (thanks to a middleware), so performance impact is negligible.
I could provide a PR, but I feel that there might be a better solution I don't see.
Workaround:
Adding patch files in composer.json for use with cweagans/composer-patches
"extra": {
"patches": {
"fruitcake/laravel-debugbar": {
"Fix debugbar boot to allow running on production": "patches/debugbar_service_provider.patch",
"Fix debugbar isEnabled to allow running on production": "patches/debugbar_is_enabled.patch"
}
}
},
patches/debugbar_service_provider.patch
--- src/ServiceProvider.php
+++ src/ServiceProvider.php
@@ -58,7 +58,7 @@
}
// Eearly return if debugbar can not enabled
- if (!LaravelDebugbar::canBeEnabled()) {
+ if (!LaravelDebugbar::canBeEnabled() && !config('debugbar.enabled', false)) {
return;
}
patches/debugbar_is_enabled.patch
--- src/LaravelDebugbar.php
+++ src/LaravelDebugbar.php
@@ -561,7 +561,7 @@
public function isEnabled(): bool
{
if ($this->enabled === null) {
- if (!static::canBeEnabled()) {
+ if (!static::canBeEnabled() && !config('debugbar.enabled', false)) {
$this->enabled = false;
} else {
$configEnabled = value(config('debugbar.enabled'));
I've been using debugbar in the production environment behind a cookie and an auth check for quite some time.
However after upgrading to v4 I noticed it no longer works.
I tried to enable it by setting config debugbar.enabled to true, yet that didn't help.
I found out that early return in
ServiceProvider->boot()ignores all the config options and is fully dependent on APP_DEBUG and APP_ENV.laravel-debugbar/src/ServiceProvider.php
Lines 63 to 66 in e00daff
Another place that ignores the config the same way is
LaravelDebugbar->isEnabled()laravel-debugbar/src/LaravelDebugbar.php
Lines 564 to 566 in e00daff
As a temporary workaround I applied a composer patch for both of those places to check the value of
config('debugbar.enabled').That's a dirty fix, but it's good enough for my purposes, and from testing I see only users passing the auth gate have access. Debugbar also turns off early in the stack if someone doesn't pass the gate (thanks to a middleware), so performance impact is negligible.
I could provide a PR, but I feel that there might be a better solution I don't see.
Workaround:
Adding patch files in composer.json for use with cweagans/composer-patches
patches/debugbar_service_provider.patch
patches/debugbar_is_enabled.patch