Skip to content

Symfony 2.8 Support #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Bootstraps/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,24 @@ public function getApplication()
$appAutoLoader = './app/autoload.php';
if (file_exists($appAutoLoader)) {
require $appAutoLoader;
} else {
} elseif (file_exists('./vendor/autoload.php')) {
require './vendor/autoload.php';
}
if(class_exists('\AppKernel')) {
$app = new \AppKernel($this->appenv, $this->debug);
} else {
if(file_exists('./app/bootstrap.php.cache') && file_exists('./app/AppKernel.php')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./app/bootstrap.php.cache may not exists beside app/AppKernel, so you should really check both individually.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is even the correct way to check if \AppKernel exists, because when class_exists returns false, it means the autoloader isn't configured correctly, which also means all namespaces and classes inside app/AppKernel.php can't be resolved, so requiring this file will fail. So I think './app/AppKernel.php' should be excluded here completely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole thing at line 55 should be replaced with

if(file_exists('./app/bootstrap.php.cache')) {
    require_once './app/bootstrap.php.cache';
}
$app = new \AppKernel($this->appenv, $this->debug);

because if \AppKernel isn't there at this point requiring app/AppKernel.php would change that much as it will fail without an= correctly configured autoloader anyway

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but with symfony 2.8 it cannot start with this. I need to require_once './app/AppKernel.php';

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it throws an error:

Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class 'AppKernel' not found in /foo/bar/vendor/php-pm/httpkernel-adapter/Bootstraps/Symfony.php:58

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mh, interesting. In my Symfony 2.8 everything works correctly. I used http://symfony.com/doc/current/book/installation.html. How have you installed Symfony 2.8?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, maybe you just upgraded from a older version or used a version pre November 2015, where AppKernel is not in the composer.json (like in the README.md of this repo noted). So, then let us require that file if it exists. But please check both files individually, app/AppKernel and app/bootstrap.php.cache. WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the pre 2.5 style of installation. Ex. cache is in app/cache instead of var/cache

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any news?

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
$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();

Expand All @@ -69,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();
Expand Down Expand Up @@ -121,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);
}
Expand All @@ -147,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');
Expand Down
3 changes: 2 additions & 1 deletion Bridges/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down