Created
November 2, 2011 12:23
-
-
Save m4rcsch/1333495 to your computer and use it in GitHub Desktop.
Environment detection based on HTTP_HOST
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 | |
/** | |
* @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