Last active
May 2, 2017 03:30
-
-
Save katzueno/40f52dbc27f248abeaad26f4acf8d473 to your computer and use it in GitHub Desktop.
concrete5 Detect Environment
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 | |
| // /application/config/bootstrap/start.php | |
| use Concrete\Core\Application\Application; | |
| /** | |
| * ---------------------------------------------------------------------------- | |
| * Instantiate concrete5 | |
| * ---------------------------------------------------------------------------- | |
| */ | |
| $app = new Application(); | |
| /** | |
| * ---------------------------------------------------------------------------- | |
| * Detect the environment based on the hostname of the server | |
| * ---------------------------------------------------------------------------- | |
| */ | |
| $app->detectEnvironment(function(){ | |
| $request = \Concrete\Core\Http\Request::getInstance(); | |
| if ( | |
| ($request->server->get('HTTP_USER_AGENT') == 'Amazon CloudFront') || | |
| ($request->getHost() == 'cdntest.exmple.co.jp') | |
| ) { | |
| return 'cdn'; | |
| } else if ( | |
| ($request->getHost() == 'develop.exmple.com') | |
| ) { | |
| return 'develop'; | |
| }); | |
| return $app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment