Skip to content

Instantly share code, notes, and snippets.

@ericclemmons
Created March 25, 2011 03:49
Show Gist options
  • Save ericclemmons/886334 to your computer and use it in GitHub Desktop.
Save ericclemmons/886334 to your computer and use it in GitHub Desktop.
Zend-friendly app.php using APPLICATION_ENV
<?php
// This is the revised `web/app.php` (click the previous edit of this gist to see the original)
//
// For those of us that deploy along-side Zend Framework apps, whose convention has been to pivot configuration
// around APPLICATION_ENV, `web/app.php` and `web/app_dev.php` is redundant.
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/bootstrap_cache.php.cache';
//require_once __DIR__.'/../app/AppCache.php';
use Symfony\Component\HttpFoundation\Request;
// Define application environment, per Zend's suggestion
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', getenv('APPLICATION_ENV') ?: 'production');
// Map Zend APPLICATION_ENV to Symfony Kernel Environment
$env = (APPLICATION_ENV === 'staging') ? 'stage'
: (APPLICATION_ENV === 'testing') ? 'test'
: (APPLICATION_ENV === 'development') ? 'dev'
: 'prod';
//$kernel = new AppCache(new AppKernel('prod', false));
$kernel = new AppKernel($env, $env !== 'prod') // Debug when not in production
$kernel->handle(Request::createFromGlobals())->send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment