From 605e4db0a6d119e5ef7b650af698889e726e6e9d Mon Sep 17 00:00:00 2001 From: BranchZero Sun Date: Wed, 22 Nov 2017 03:07:25 +0800 Subject: [PATCH 1/2] Support Lumen --- Bootstraps/Laravel.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Bootstraps/Laravel.php b/Bootstraps/Laravel.php index 52e231b..4054aa5 100644 --- a/Bootstraps/Laravel.php +++ b/Bootstraps/Laravel.php @@ -58,11 +58,17 @@ public function requestClass() { */ public function getApplication() { - require_once 'bootstrap/autoload.php'; + if (file_exists('bootstrap/autoload.php')) { + require_once 'bootstrap/autoload.php'; + } // Laravel 5 / Lumen + $isLaravel = true; if (file_exists('bootstrap/app.php')) { $this->app = require_once 'bootstrap/app.php'; + if (str_contains($this->app->version(), 'Lumen')) { + $isLaravel = false; + } } // Laravel 4 @@ -74,7 +80,7 @@ public function getApplication() throw new \RuntimeException('Laravel bootstrap file not found'); } - $kernel = $this->app->make('Illuminate\Contracts\Http\Kernel'); + $kernel = $this->app->make($isLaravel ? 'Illuminate\Contracts\Http\Kernel' : 'Laravel\Lumen\Application'); return $kernel; } From d9c7052c8f3d21e5c1cca67b7c72fea46afc0315 Mon Sep 17 00:00:00 2001 From: BranchZero Sun Date: Wed, 22 Nov 2017 03:12:09 +0800 Subject: [PATCH 2/2] Remove str_contains --- Bootstraps/Laravel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bootstraps/Laravel.php b/Bootstraps/Laravel.php index 4054aa5..efb3796 100644 --- a/Bootstraps/Laravel.php +++ b/Bootstraps/Laravel.php @@ -66,7 +66,7 @@ public function getApplication() $isLaravel = true; if (file_exists('bootstrap/app.php')) { $this->app = require_once 'bootstrap/app.php'; - if (str_contains($this->app->version(), 'Lumen')) { + if (substr($this->app->version(), 0, 5) === 'Lumen') { $isLaravel = false; } }