diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index a282e305..d3a3d85d 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -125,8 +125,9 @@ public function __construct($app = null) $this->is_lumen = Str::contains($this->version, 'Lumen'); if ($this->is_lumen) { $this->version = Str::betweenFirst($app->version(), '(', ')'); + } else { + $this->setRequestIdGenerator(new RequestIdGenerator()); } - $this->setRequestIdGenerator(new RequestIdGenerator()); } /** @@ -209,13 +210,16 @@ public function boot() if ($this->shouldCollect('time', true)) { $startTime = $app['request']->server('REQUEST_TIME_FLOAT'); - $this->addCollector(new TimeDataCollector($startTime)); + + if (!$this->hasCollector('time')) { + $this->addCollector(new TimeDataCollector($startTime)); + } if ($config->get('debugbar.options.time.memory_usage')) { $this['time']->showMemoryUsage(); } - if ($startTime) { + if ($startTime && !$this->isLumen()) { $app->booted( function () use ($startTime) { $this->addMeasure('Booting', $startTime, microtime(true), [], 'time'); diff --git a/src/LumenServiceProvider.php b/src/LumenServiceProvider.php index ed629711..0afa1294 100644 --- a/src/LumenServiceProvider.php +++ b/src/LumenServiceProvider.php @@ -3,12 +3,39 @@ namespace Barryvdh\Debugbar; use Laravel\Lumen\Application; +use DebugBar\DataCollector\TimeDataCollector; class LumenServiceProvider extends ServiceProvider { /** @var Application */ protected $app; + public function boot() + { + parent::boot(); + + $this->app->call( + function () { + $debugBar = $this->app->get(LaravelDebugbar::class); + if ($debugBar->shouldCollect('time', true)) { + $startTime = $this->app['request']->server('REQUEST_TIME_FLOAT'); + + if (!$debugBar->hasCollector('time')) { + $debugBar->addCollector(new TimeDataCollector($startTime)); + } + + if ($this->app['config']->get('debugbar.options.time.memory_usage')) { + $debugBar['time']->showMemoryUsage(); + } + + if ($startTime) { + $debugBar->addMeasure('Booting', $startTime, microtime(true), [], 'time'); + } + } + } + ); + } + /** * Get the active router. *