Skip to content

Instantly share code, notes, and snippets.

@wpottier
Created December 8, 2016 10:40
Show Gist options
  • Save wpottier/64d85b9dfb39593b8406302f11ad086b to your computer and use it in GitHub Desktop.
Save wpottier/64d85b9dfb39593b8406302f11ad086b to your computer and use it in GitHub Desktop.
Symfony unified front controller
<?php
use Symfony\Component\HttpFoundation\Request;
umask(0000);
if (!isset($_SERVER['APPLICATION_ENV'])) {
$_SERVER['APPLICATION_ENV'] = 'prod';
}
/**
* @var Composer\Autoload\ClassLoader
*/
$loader = require __DIR__.'/../app/autoload.php';
if ($_SERVER['APPLICATION_ENV'] == 'prod') {
include_once __DIR__.'/../var/bootstrap.php.cache';
}
else {
Debug::enable();
}
if ($_SERVER['APPLICATION_ENV'] == 'prod' && isset($_SERVER['AUTOLOAD_APC']) && $_SERVER['AUTOLOAD_APC']) {
// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.
$apcLoader = new Symfony\Component\ClassLoader\ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);
}
$kernel = new AppKernel($_SERVER['APPLICATION_ENV'], $_SERVER['APPLICATION_ENV'] == 'dev');
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
@pifou42
Copy link

pifou42 commented Dec 21, 2016

Par hasard, il ne manquerait pas le
use Symfony\Component\Debug\Debug;
?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment