Created
June 23, 2014 17:17
-
-
Save mtthlm/d2dc97444558c1cfb907 to your computer and use it in GitHub Desktop.
Enhanced Foolproof Multi-Environment Config
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 | |
define('CRAFT_ENVIRONMENT', call_user_func_array(function ($environments, $fallback) { | |
if (array_key_exists('APP_ENV', $_SERVER) && in_array($environment = $_SERVER['APP_ENV'], array_keys($environments))) { | |
return $environment; | |
} | |
foreach ($environments as $environment => $value) { | |
$serverName = $_SERVER['SERVER_NAME']; | |
if ((is_array($value) && in_array($serverName, $value)) || $e == $value) { | |
return $environment; | |
} | |
} | |
return $fallback; | |
}, array( | |
// Environment Definitions | |
array( | |
'local' => array('local.project.com'), | |
'dev' => array('dev.project.com'), | |
'staging' => array('staging.project.com'), | |
), | |
// Default Environment | |
'production', | |
))); | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment