Skip to content

Instantly share code, notes, and snippets.

@wpottier
Created June 19, 2014 14:48
Show Gist options
  • Select an option

  • Save wpottier/a967fd101991d7bbf9bb to your computer and use it in GitHub Desktop.

Select an option

Save wpottier/a967fd101991d7bbf9bb to your computer and use it in GitHub Desktop.
app.php multi-env
<?php
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
$_SERVER['APPLICATION_ENV'] = isset($_SERVER['APPLICATION_ENV']) ? $_SERVER['APPLICATION_ENV'] : 'prod';
if($_SERVER['APPLICATION_ENV'] == 'dev') {
ini_set('display_errors', 'On');
}
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
if ($_SERVER['APPLICATION_ENV'] == 'dev') {
Debug::enable();
}
// 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 ($_SERVER['APPLICATION_ENV'] == 'prod') {
$apcLoader = new ApcClassLoader($_SERVER['APPLICATION_APC_PREFIX'] ? $_SERVER['APPLICATION_APC_PREFIX'] : 'sf2', $loader);
$loader->unregister();
$apcLoader->register(true);
}
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';
$kernel = new AppKernel($_SERVER['APPLICATION_ENV'], $_SERVER['APPLICATION_ENV'] == 'dev');
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$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