Skip to content

Commit

Permalink
Merge branch '69-switch-environment-detection-in-the-app'
Browse files Browse the repository at this point in the history
  • Loading branch information
kip9 committed Jan 28, 2014
2 parents a8f36b4 + 9c45688 commit 7f3c6a0
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,47 @@
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define('ENVIRONMENT', 'development');

// Looking for local environment configuration under application/config/environment.php
$appDir = dirname(__FILE__);
if(file_exists($appDir)){
$localEnvConfigFile = $appDir.'/application/config/environment.php';
if(file_exists($localEnvConfigFile)){
include_once($localEnvConfigFile);
}
}
// Looking for global environment configuration under /etc/nilai/environment.php
const NILAI_ENV_CONFIG_GLOBAL = '/etc/nilai/environment.php';
if(!defined('ENVIRONMENT')){
if(file_exists(NILAI_ENV_CONFIG_GLOBAL)){
include_once(NILAI_ENV_CONFIG_GLOBAL);
}
}
if(!defined('ENVIRONMENT')){
define('ENVIRONMENT', 'production');
}

/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
* All environments report lots of info except of production
*/

if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;

case 'staging':
break;
case 'production':
error_reporting(0);
break;

default:
exit('The application environment is not set correctly.');
error_reporting(E_ALL);
break;

}
}

Expand Down

0 comments on commit 7f3c6a0

Please sign in to comment.