From ef8e5b47f3f6d959f108a5b7ae090a27c919067e Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Sat, 5 May 2018 07:16:28 +0800 Subject: [PATCH 1/2] fix rebindKernelContainer --- src/Server/Application.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Server/Application.php b/src/Server/Application.php index 9ae1c007..f975485c 100644 --- a/src/Server/Application.php +++ b/src/Server/Application.php @@ -426,6 +426,21 @@ protected function preResolveInstances($application) } } + /** + * Rebind laravel's container in kernel. + */ + protected function rebindKernelContainer($kernel) + { + $application = $this->application; + + $closure = function () use ($application) { + $this->app = $application; + }; + + $resetKernel = $closure->bindTo($kernel, $kernel); + $resetKernel(); + } + /** * Clone laravel app and kernel while being cloned. */ @@ -436,7 +451,7 @@ public function __clone() $this->application = $application; if ($this->framework === 'laravel') { - $this->kernel->setApplication($application); + $this->rebindKernelContainer($this->kernel); } } } From 35cdd4b4d4c73483017632d11a49352c9b30d029 Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Sat, 5 May 2018 07:18:52 +0800 Subject: [PATCH 2/2] replace kernel with get kernel in clone --- src/Server/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server/Application.php b/src/Server/Application.php index f975485c..4997f59b 100644 --- a/src/Server/Application.php +++ b/src/Server/Application.php @@ -451,7 +451,7 @@ public function __clone() $this->application = $application; if ($this->framework === 'laravel') { - $this->rebindKernelContainer($this->kernel); + $this->rebindKernelContainer($this->getKernel()); } } }