From a9d8f39382cb746a164f506d2abf9ceed0ff327b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 3 May 2010 09:54:17 +0200 Subject: [PATCH] [Foundation] moved some Kernel initializations in the boot() method to speed up creation of Kernel instances --- src/Symfony/Foundation/Kernel.php | 22 ++++++++++------------ src/Symfony/Foundation/bootstrap.php | 22 ++++++++++------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/Symfony/Foundation/Kernel.php b/src/Symfony/Foundation/Kernel.php index 20cbae14754b..bcc013b5a6b1 100644 --- a/src/Symfony/Foundation/Kernel.php +++ b/src/Symfony/Foundation/Kernel.php @@ -50,28 +50,23 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable */ public function __construct($environment, $debug) { + $this->environment = $environment; $this->debug = (Boolean) $debug; + $this->booted = false; + $this->rootDir = realpath($this->registerRootDir()); + $this->name = basename($this->rootDir); + if ($this->debug) { ini_set('display_errors', 1); error_reporting(-1); + + $this->startTime = microtime(true); } else { ini_set('display_errors', 0); } - - if ($this->debug) - { - $this->startTime = microtime(true); - } - - $this->booted = false; - $this->environment = $environment; - $this->bundles = $this->registerBundles(); - $this->bundleDirs = $this->registerBundleDirs(); - $this->rootDir = realpath($this->registerRootDir()); - $this->name = basename($this->rootDir); } abstract public function registerRootDir(); @@ -111,6 +106,9 @@ public function boot() throw new \LogicException('The kernel is already booted.'); } + $this->bundles = $this->registerBundles(); + $this->bundleDirs = $this->registerBundleDirs(); + // initialize the container $this->container = $this->initializeContainer(); $this->container->setService('kernel', $this); diff --git a/src/Symfony/Foundation/bootstrap.php b/src/Symfony/Foundation/bootstrap.php index 65b6ba7c731c..81161b06a33a 100644 --- a/src/Symfony/Foundation/bootstrap.php +++ b/src/Symfony/Foundation/bootstrap.php @@ -390,28 +390,23 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable public function __construct($environment, $debug) { + $this->environment = $environment; $this->debug = (Boolean) $debug; + $this->booted = false; + $this->rootDir = realpath($this->registerRootDir()); + $this->name = basename($this->rootDir); + if ($this->debug) { ini_set('display_errors', 1); error_reporting(-1); + + $this->startTime = microtime(true); } else { ini_set('display_errors', 0); } - - if ($this->debug) - { - $this->startTime = microtime(true); - } - - $this->booted = false; - $this->environment = $environment; - $this->bundles = $this->registerBundles(); - $this->bundleDirs = $this->registerBundleDirs(); - $this->rootDir = realpath($this->registerRootDir()); - $this->name = basename($this->rootDir); } abstract public function registerRootDir(); @@ -438,6 +433,9 @@ public function boot() throw new \LogicException('The kernel is already booted.'); } + $this->bundles = $this->registerBundles(); + $this->bundleDirs = $this->registerBundleDirs(); + $this->container = $this->initializeContainer(); $this->container->setService('kernel', $this);