Created
November 28, 2012 19:22
-
-
Save frak/4163438 to your computer and use it in GitHub Desktop.
Symfony2: Remove the need for app_dev.php
This file contains hidden or 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 | |
$env = 'prod'; | |
$debug = false; | |
if(isset($_SERVER['APP_KERNEL'])) { | |
switch($_SERVER['APP_KERNEL']) { | |
case 'test': | |
case 'qa': | |
case 'dev': | |
$env = $_SERVER['APP_KERNEL']; | |
break; | |
} | |
} | |
if($env !== 'prod') { | |
$debug = true; | |
} | |
use Symfony\Component\ClassLoader\ApcClassLoader; | |
use Symfony\Component\HttpFoundation\Request; | |
$loader = require_once __DIR__.'/../app/bootstrap.php.cache'; | |
// Use APC for autoloading to improve performance. | |
// Change 'sf2' to a unique prefix in order to prevent cache key conflicts | |
// with other applications also using APC. | |
if($env == 'prod') { | |
$loader = new ApcClassLoader('apc_app_loading_cache', $loader); | |
$loader->register(true); | |
} | |
require_once __DIR__.'/../app/AppKernel.php'; | |
$kernel = new AppKernel($env, $debug); | |
$kernel->loadClassCache(); | |
if($env == 'prod') { | |
require_once __DIR__.'/../app/AppCache.php'; | |
$kernel = new AppCache($kernel); | |
} | |
$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