diff --git a/framework/core/src/Foundation/AbstractServer.php b/framework/core/src/Foundation/AbstractServer.php index 091166eb6..5f6115029 100644 --- a/framework/core/src/Foundation/AbstractServer.php +++ b/framework/core/src/Foundation/AbstractServer.php @@ -62,8 +62,6 @@ abstract class AbstractServer if (file_exists($file = $this->basePath.'/config.php')) { $this->config = include $file; } - - $this->app = $this->getApp(); } /** @@ -135,6 +133,10 @@ abstract class AbstractServer */ protected function getApp() { + if ($this->app !== null) { + return $this->app; + } + date_default_timezone_set('UTC'); $app = new Application($this->basePath, $this->publicPath); @@ -182,6 +184,8 @@ abstract class AbstractServer $app->boot(); + $this->app = $app; + return $app; } diff --git a/framework/core/src/Http/AbstractServer.php b/framework/core/src/Http/AbstractServer.php index dc72b154e..cb82741fc 100644 --- a/framework/core/src/Http/AbstractServer.php +++ b/framework/core/src/Http/AbstractServer.php @@ -44,9 +44,11 @@ abstract class AbstractServer extends BaseAbstractServer */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out = null) { - $this->collectGarbage($this->app); + $app = $this->getApp(); - $middleware = $this->getMiddleware($this->app); + $this->collectGarbage($app); + + $middleware = $this->getMiddleware($app); return $middleware($request, $response, $out); }