diff --git a/Bootstraps/Symfony.php b/Bootstraps/Symfony.php index 0cf48a6..c672b2b 100644 --- a/Bootstraps/Symfony.php +++ b/Bootstraps/Symfony.php @@ -49,16 +49,24 @@ public function getApplication() $appAutoLoader = './app/autoload.php'; if (file_exists($appAutoLoader)) { require $appAutoLoader; - } else { + } elseif (file_exists('./vendor/autoload.php')) { require './vendor/autoload.php'; } + if(class_exists('\AppKernel')) { + $app = new \AppKernel($this->appenv, $this->debug); + } else { + if(file_exists('./app/bootstrap.php.cache') && file_exists('./app/AppKernel.php')) { + require_once './app/bootstrap.php.cache'; + require_once './app/AppKernel.php'; + $app = new \AppKernel($this->appenv, $this->debug); + } - //since we need to change some services, we need to manually change some services - $app = new \AppKernel($this->appenv, $this->debug); + } + //since we need to change some services, we need to manually change some services //we need to change some services, before the boot, because they would otherwise //be instantiated and passed to other classes which makes it impossible to replace them. - Utils::bindAndCall(function() use ($app) { + Utils::bindAndCall(function () use ($app) { // init bundles $app->initializeBundles(); @@ -69,12 +77,12 @@ public function getApplication() //now we can modify the container $nativeStorage = new StrongerNativeSessionStorage( $app->getContainer()->getParameter('session.storage.options'), - $app->getContainer()->has('session.handler') ? $app->getContainer()->get('session.handler'): null, + $app->getContainer()->has('session.handler') ? $app->getContainer()->get('session.handler') : null, $app->getContainer()->get('session.storage.metadata_bag') ); $app->getContainer()->set('session.storage.native', $nativeStorage); - Utils::bindAndCall(function() use ($app) { + Utils::bindAndCall(function () use ($app) { foreach ($app->getBundles() as $bundle) { $bundle->setContainer($app->container); $bundle->boot(); @@ -121,7 +129,7 @@ public function postHandle($app) //->Twig_Loader_Filesystem if ($container->has('twig.loader')) { $twigLoader = $container->get('twig.loader'); - Utils::bindAndCall(function() use ($twigLoader) { + Utils::bindAndCall(function () use ($twigLoader) { foreach ($twigLoader->cache as $path) { ppm_register_file($path); } @@ -147,7 +155,7 @@ public function postHandle($app) if ($profiler->has('db')) { Utils::bindAndCall(function () { //$logger: \Doctrine\DBAL\Logging\DebugStack - foreach ($this->loggers as $logger){ + foreach ($this->loggers as $logger) { Utils::hijackProperty($logger, 'queries', []); } }, $profiler->get('db'), null, 'Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector'); diff --git a/Bridges/HttpKernel.php b/Bridges/HttpKernel.php index fdb7d3e..d93dabb 100644 --- a/Bridges/HttpKernel.php +++ b/Bridges/HttpKernel.php @@ -147,7 +147,8 @@ protected function mapRequest(ReactRequest $reactRequest) $post = $reactRequest->getPost(); $class = $this->bootstrap->requestClass(); - + + SymfonyRequest::setTrustedProxies(array($_SERVER['REMOTE_ADDR'])); $syRequest = new $class($query, $post, $attributes = [], $cookies, $files, $_SERVER, $reactRequest->getBody()); $syRequest->setMethod($method);