Skip to content

Commit 7529206

Browse files
author
Xavier Barbosa
authored
Merge pull request #12 from madewithlove/bugfix/respect-enable-state
Respect env configuration
2 parents 97f547b + 0aafdab commit 7529206

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/ServiceProvider.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class ServiceProvider extends BaseServiceProvider
1313
*/
1414
public function boot()
1515
{
16+
// Obey the same rules of laravel debugbar so we do not enable profiling where is not expected too.
17+
if (!$this->isEnabled()) {
18+
return;
19+
}
20+
1621
if ($this->app->runningInConsole()) {
1722
$this->commands([
1823
Debug::class,
@@ -37,4 +42,18 @@ public function register()
3742
{
3843
$this->app->register(DebugbarServiceProvider::class);
3944
}
45+
46+
/**
47+
* @return bool
48+
*/
49+
protected function isEnabled()
50+
{
51+
$enabled = $this->app['config']->get('debugbar.enabled');
52+
53+
if (is_null($enabled)) {
54+
$enabled = $this->app['config']->get('app.debug');
55+
}
56+
57+
return (bool) $enabled;
58+
}
4059
}

0 commit comments

Comments
 (0)