From 62f4f3a4d3b33a0dd573e36e0601bf43cf4f960e Mon Sep 17 00:00:00 2001 From: Matthias Molitor Date: Mon, 31 Aug 2015 22:22:13 +0200 Subject: [PATCH 1/3] load the autoload file in the app directory, if available (the Symfony standard edition uses that autoload file to configure the annotation class loading) --- Bootstraps/Symfony.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Bootstraps/Symfony.php b/Bootstraps/Symfony.php index 9754044..3c474ae 100644 --- a/Bootstraps/Symfony.php +++ b/Bootstraps/Symfony.php @@ -32,6 +32,13 @@ public function getApplication() require_once './app/AppKernel.php'; } + $info = new \ReflectionClass('AppKernel'); + $appDir = dirname($info->getFileName()); + $symfonyAutoload = $appDir . '/autoload.php'; + if (is_file($symfonyAutoload)) { + require_once $symfonyAutoload; + } + $app = new \AppKernel($this->appenv, false); $app->loadClassCache(); From 3f3db0df7ccbbf03fa325eed4bbb5965e4b0b15f Mon Sep 17 00:00:00 2001 From: Matthias Molitor Date: Mon, 31 Aug 2015 22:33:39 +0200 Subject: [PATCH 2/3] extracted method and documented approach --- Bootstraps/Symfony.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Bootstraps/Symfony.php b/Bootstraps/Symfony.php index 3c474ae..997ae2a 100644 --- a/Bootstraps/Symfony.php +++ b/Bootstraps/Symfony.php @@ -32,12 +32,7 @@ public function getApplication() require_once './app/AppKernel.php'; } - $info = new \ReflectionClass('AppKernel'); - $appDir = dirname($info->getFileName()); - $symfonyAutoload = $appDir . '/autoload.php'; - if (is_file($symfonyAutoload)) { - require_once $symfonyAutoload; - } + $this->includeAutoload(); $app = new \AppKernel($this->appenv, false); $app->loadClassCache(); @@ -52,4 +47,22 @@ public function getStack(Builder $stack) { return $stack; } + + /** + * Includes the autoload file from the app directory, if available. + * + * The Symfony standard edition configures the annotation class loading + * in that file. + * The alternative bootstrap.php.cache cannot be included as that leads + * to "Cannot redeclare class" error, when starting php-pm. + */ + protected function includeAutoload() + { + $info = new \ReflectionClass('AppKernel'); + $appDir = dirname($info->getFileName()); + $symfonyAutoload = $appDir . '/autoload.php'; + if (is_file($symfonyAutoload)) { + require_once $symfonyAutoload; + } + } } From e5a5e5c8b0b4123c79aa8a0341dccd2c170f6ed6 Mon Sep 17 00:00:00 2001 From: Matthias Molitor Date: Mon, 31 Aug 2015 22:45:32 +0200 Subject: [PATCH 3/3] removed unused use-statement --- Bootstraps/Symfony.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Bootstraps/Symfony.php b/Bootstraps/Symfony.php index 997ae2a..c2524b2 100644 --- a/Bootstraps/Symfony.php +++ b/Bootstraps/Symfony.php @@ -3,7 +3,6 @@ namespace PHPPM\Bootstraps; use Stack\Builder; -use Symfony\Component\HttpKernel\HttpCache\Store; /** * A default bootstrap for the Symfony framework