Skip to content

Commit 3f3db0d

Browse files
author
Matthias Molitor
committed
extracted method and documented approach
1 parent 62f4f3a commit 3f3db0d

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

Bootstraps/Symfony.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ public function getApplication()
3232
require_once './app/AppKernel.php';
3333
}
3434

35-
$info = new \ReflectionClass('AppKernel');
36-
$appDir = dirname($info->getFileName());
37-
$symfonyAutoload = $appDir . '/autoload.php';
38-
if (is_file($symfonyAutoload)) {
39-
require_once $symfonyAutoload;
40-
}
35+
$this->includeAutoload();
4136

4237
$app = new \AppKernel($this->appenv, false);
4338
$app->loadClassCache();
@@ -52,4 +47,22 @@ public function getStack(Builder $stack)
5247
{
5348
return $stack;
5449
}
50+
51+
/**
52+
* Includes the autoload file from the app directory, if available.
53+
*
54+
* The Symfony standard edition configures the annotation class loading
55+
* in that file.
56+
* The alternative bootstrap.php.cache cannot be included as that leads
57+
* to "Cannot redeclare class" error, when starting php-pm.
58+
*/
59+
protected function includeAutoload()
60+
{
61+
$info = new \ReflectionClass('AppKernel');
62+
$appDir = dirname($info->getFileName());
63+
$symfonyAutoload = $appDir . '/autoload.php';
64+
if (is_file($symfonyAutoload)) {
65+
require_once $symfonyAutoload;
66+
}
67+
}
5568
}

0 commit comments

Comments
 (0)