Created
September 7, 2012 14:35
-
-
Save darioghilardi/3666711 to your computer and use it in GitHub Desktop.
Environments setup
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 | |
/** | |
* Environment selection: | |
* Set the correct environment based on the current request. | |
* | |
* Development is the default environment. | |
* Test gets called when running behat tests and li3 tests: | |
* For behat look at features/bootstrap/LithiumAcceptanceTester.php where an environment variable is set. | |
* For li3 it's switched here based on the command parameter of $request. | |
* | |
* As behat runs on jenkins too, and because jenkins uses a db declations provided by the ini file, an environment | |
* variable check is needed to recognize jenkins builds. | |
* | |
* For every other environment the HTTP_LITHIUM_ENVIRONMENT variable should be set. | |
*/ | |
use lithium\core\Environment; | |
use lithium\action\Request; | |
Environment::is(function($request) { | |
// Production settings | |
$service = $request->env('HTTP_LITHIUM_ENVIRONMENT'); | |
// CI environment | |
$ci = $request->env('JENKINS_HOME'); | |
// Local behat environment | |
$behat = $request->env('HTTP_LITHIUM_BEHAT'); | |
switch (true) { | |
case (isset($service) || isset($ci)): | |
return 'service'; | |
case (($request->command == 'test') || (isset($behat))): | |
return 'test'; | |
default: | |
return 'development'; | |
} | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @ingo86, where does this go in your project? Do you reference it in
app/config/bootstrap/app.php
?