From fb0ed549949ebdca7a9648aab5338c7193525b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Ma=C5=82ecki?= Date: Fri, 25 Mar 2016 14:09:23 +0100 Subject: [PATCH 1/2] symfony 2.8 bootstrap --- Bootstraps/Symfony.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Bootstraps/Symfony.php b/Bootstraps/Symfony.php index 0cf48a6..29b648d 100644 --- a/Bootstraps/Symfony.php +++ b/Bootstraps/Symfony.php @@ -45,16 +45,26 @@ public function getStaticDirectory() */ public function getApplication() { + + + // include applications autoload $appAutoLoader = './app/autoload.php'; if (file_exists($appAutoLoader)) { require $appAutoLoader; - } else { + $app = new \AppKernel($this->appenv, $this->debug); + } elseif(file_exists('./vendor/autoload.php')) { require './vendor/autoload.php'; + $app = new \AppKernel($this->appenv, $this->debug); + } else { + $loader = require_once __DIR__.'./app/bootstrap.php.cache'; + require_once __DIR__.'/../app/AppKernel.php'; + $kernel = new AppKernel('prod', false); + } //since we need to change some services, we need to manually change some services - $app = new \AppKernel($this->appenv, $this->debug); + //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. From 8bbef678c9ddce2e3a8c0f483fd9fc2176dfc611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Ma=C5=82ecki?= Date: Fri, 25 Mar 2016 14:10:34 +0100 Subject: [PATCH 2/2] symfony 2.8 bootstrap symfony 2.8 loader symfony 2.8 app kernel loader fix bridge fix symfony2.8 for the win --- Bootstraps/Symfony.php | 30 ++++++++++++++---------------- Bridges/HttpKernel.php | 3 ++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Bootstraps/Symfony.php b/Bootstraps/Symfony.php index 29b648d..c672b2b 100644 --- a/Bootstraps/Symfony.php +++ b/Bootstraps/Symfony.php @@ -45,30 +45,28 @@ public function getStaticDirectory() */ public function getApplication() { - - - // include applications autoload $appAutoLoader = './app/autoload.php'; if (file_exists($appAutoLoader)) { require $appAutoLoader; - $app = new \AppKernel($this->appenv, $this->debug); - } elseif(file_exists('./vendor/autoload.php')) { + } elseif (file_exists('./vendor/autoload.php')) { require './vendor/autoload.php'; + } + if(class_exists('\AppKernel')) { $app = new \AppKernel($this->appenv, $this->debug); } else { - $loader = require_once __DIR__.'./app/bootstrap.php.cache'; - require_once __DIR__.'/../app/AppKernel.php'; - $kernel = new AppKernel('prod', false); + 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 - - //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(); @@ -79,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(); @@ -131,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); } @@ -157,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);