diff --git a/src/DDocServiceProvider.php b/src/DDocServiceProvider.php index e57be2e..8934ff1 100644 --- a/src/DDocServiceProvider.php +++ b/src/DDocServiceProvider.php @@ -29,7 +29,8 @@ public function boot() __DIR__.'/../public/' => public_path(''), ]); // 注册路由 - if (! $this->app->routesAreCached()) { + if ((method_exists($this->app, 'routesAreCached') && !$this->app->routesAreCached()) + || $this->isLumen()) { require __DIR__.'/routes.php'; } } @@ -43,4 +44,9 @@ public function register() { $this->app->register('Barryvdh\Snappy\ServiceProvider'); } -} \ No newline at end of file + + protected function isLumen() + { + return strpos($this->app->version(), 'Lumen') !== false; + } +}