Closed macburgee1 closed 5 years ago
Could add some sort of of environment variable like $_SERVER['UNLCMSENV']
Sure, just add the following to .htaccess:
SetEnv UNLCMSENV development
.htaccess is under version control. If we set the environment variable there, it'll follow Drupal through all environments that run in Apache. What are our options for setting the variable in either Apache's global config or in individual VHOSTs?
Oh, sorry. I thought there was a separate .htaccess.sample file that was versioned, and a copy of that was used for local config.
I see .htaccess.sample in UNL-CMS-2... hmm. Eric is looking into Aegir. Let's table this for now.
I actually just found a good place to put it (just below the RewriteMap rules that have to be in the main config anyway). Its enable on prod and staging now.
@tsteiner - Thanks! Is the variable called 'UNLCMSENV'? What are values for prod and stage?
Below is some example code we'll be using:
<?php
$environment = getenv('UNLCMSENV');
if ($environment == 'production') {
$config['config_split.config_split.production']['status'] = TRUE;
$config['config_split.config_split.stage']['status'] = FALSE;
$config['config_split.config_split.development']['status'] = FALSE;
}
elseif ($environment == 'stage') {
$config['config_split.config_split.production']['status'] = FALSE;
$config['config_split.config_split.stage']['status'] = TRUE;
$config['config_split.config_split.development']['status'] = FALSE;
}
else {
$config['config_split.config_split.production']['status'] = FALSE;
$config['config_split.config_split.stage']['status'] = FALSE;
$config['config_split.config_split.development']['status'] = TRUE;
}
?>
Yes, its named "UNLCMSENV", and its value is currently "development" on unlcms-staging.unl.edu, and "production" on unlcms.unl.edu.
Could we change the value on stage to 'stage'?
Done!
Thanks! @tsteiner. Closing this issue. Remaining integration with Config Split will happen over on #35.
It will be useful in a number of instances for Drupal to know where it's being run (e.g. production, local development). The primary use case is for the Config Split module.