Skip to content

Instantly share code, notes, and snippets.

@m4rcsch
Created November 2, 2011 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m4rcsch/1333495 to your computer and use it in GitHub Desktop.
Save m4rcsch/1333495 to your computer and use it in GitHub Desktop.
Environment detection based on HTTP_HOST
<?php
/**
* @author 2011 weluse GmbH, Marc Schwering
*/
use lithium\core\Environment;
Environment::is(function($request) {
$http_host = $request->env('HTTP_HOST');
//in array search example
/*if (in_array($http_host, array('domain', 'domain2' , 'domain3'))) {
return 'development';
}
if ($http_host == 'subdomain.weluse.de' || $http_host == 'domain.test') {
return 'test';
}*/
//str pos search analouge to general environment detection:
if (strpos($http_host, '.local')){
ini_set("display_errors", 1);
return 'development';
}
if (strpos($http_host,'.test') || strpos($http_host, '.weluse.de')){
ini_set("display_errors", 1);
return 'test';
}
return 'production';
});
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment