Skip to content

Commit e7c3f56

Browse files
authored
fix: load routes and commands in the service provider's boot method (#1197)
1 parent b2d3907 commit e7c3f56

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/ServiceProvider.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public function register()
2626
$configPath = __DIR__ . '/../config/debugbar.php';
2727
$this->mergeConfigFrom($configPath, 'debugbar');
2828

29-
$this->loadRoutesFrom(realpath(__DIR__ . '/debugbar-routes.php'));
30-
3129
$this->app->alias(
3230
DataFormatter::class,
3331
DataFormatterInterface::class
@@ -90,8 +88,6 @@ public function register($engine, \Closure $resolver)
9088
}
9189
);
9290

93-
$this->commands(['command.debugbar.clear']);
94-
9591
Collection::macro('debug', function () {
9692
debug($this);
9793
return $this;
@@ -108,7 +104,13 @@ public function boot()
108104
$configPath = __DIR__ . '/../config/debugbar.php';
109105
$this->publishes([$configPath => $this->getConfigPath()], 'config');
110106

107+
$this->loadRoutesFrom(realpath(__DIR__ . '/debugbar-routes.php'));
108+
111109
$this->registerMiddleware(InjectDebugbar::class);
110+
111+
if ($this->app->runningInConsole()) {
112+
$this->commands(['command.debugbar.clear']);
113+
}
112114
}
113115

114116
/**

0 commit comments

Comments
 (0)