diff --git a/src/Server/Application.php b/src/Server/Application.php index 9ae1c007..4997f59b 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->getKernel()); } } }