Skip to content

Instantly share code, notes, and snippets.

@katzueno
Last active May 2, 2017 03:30
Show Gist options
  • Select an option

  • Save katzueno/40f52dbc27f248abeaad26f4acf8d473 to your computer and use it in GitHub Desktop.

Select an option

Save katzueno/40f52dbc27f248abeaad26f4acf8d473 to your computer and use it in GitHub Desktop.
concrete5 Detect Environment
<?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