Skip to content

Commit 349b65c

Browse files
committed
Merge pull request #8 from Matthimatiker/feature/symfony_autoload
Support autoload mechanism of Symfony standard
2 parents c85e122 + e5a5e5c commit 349b65c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Bootstraps/Symfony.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace PHPPM\Bootstraps;
44

55
use Stack\Builder;
6-
use Symfony\Component\HttpKernel\HttpCache\Store;
76

87
/**
98
* A default bootstrap for the Symfony framework
@@ -32,6 +31,8 @@ public function getApplication()
3231
require_once './app/AppKernel.php';
3332
}
3433

34+
$this->includeAutoload();
35+
3536
$app = new \AppKernel($this->appenv, false);
3637
$app->loadClassCache();
3738

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

0 commit comments

Comments
 (0)