mergeConfigFrom($configPath, 'debugbar'); $this->app->alias( DataFormatter::class, DataFormatterInterface::class ); $this->app->singleton(LaravelDebugbar::class, function ($app) { return new LaravelDebugbar($app); }); $this->app->singleton(SymfonyHttpDriver::class, function ($app) { return new SymfonyHttpDriver($app->make(SessionManager::class)); }); $this->app->alias(LaravelDebugbar::class, 'debugbar'); Collection::macro('debug', function () { debug($this); return $this; }); } /** * Bootstrap the application events. * * @return void */ public function boot() { $configPath = __DIR__ . '/../config/debugbar.php'; $this->publishes([$configPath => $this->getConfigPath()], 'config'); $this->loadRoutesFrom(__DIR__ . '/debugbar-routes.php'); $this->registerMiddleware(InjectDebugbar::class); $this->commands([ClearCommand::class]); } /** * Get the active router. * * @return Router */ protected function getRouter() { return $this->app['router']; } /** * Get the config path * * @return string */ protected function getConfigPath() { return config_path('debugbar.php'); } /** * Register the Debugbar Middleware * * @param string $middleware */ protected function registerMiddleware($middleware) { /** @var \Illuminate\Foundation\Http\Kernel $kernel */ $kernel = $this->app[Kernel::class]; $kernel->pushMiddleware($middleware); if (isset($kernel->getMiddlewareGroups()['web'])) { $kernel->appendMiddlewareToGroup('web', $middleware); } } }