Created
December 8, 2016 10:40
-
-
Save wpottier/64d85b9dfb39593b8406302f11ad086b to your computer and use it in GitHub Desktop.
Symfony unified front controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Par hasard, il ne manquerait pas le
use Symfony\Component\Debug\Debug;
?