Environment dependend workflow with configuration management When using Drupal 7 with larger projects, we used a Custom module together with Features, Environment and Environment Indicator modules to keep special environment settings apart. We had at least one feature module for each environment containing something like this:

Production


no dblog module active
no devel modules
all sorts of caching enabled
red coloring on Environment Indicator


Staging / Testing


dblog module active
no devel modules
some caching disabled
yellow coloring on Environment Indicator


Staging / Testing


dblog module active
all sorts of devel modules active
caching disabled
green coloring on Environment Indicator


When developing we used to push new code to production when it was finished and tested. After successful deployment, we cloned the database down to staging and development environments to be sync with the state of production in terms of new content. After that we would run commands like drush env-switch staging to tell Drupal to set environment to Staging and run some custom hooks that would enable the Staging feature module and its settings and dependencies. This way Production, Staging and Develop had different sets of modules and configuration but the same state of content.

After reading and testing into Configuration Management, i fail to see how i could accomplish such a workflow. When using drush config-export staging it exports all current settings into staging directory, which i can check into git and deploy it on my server. Features for D8 lacks of some things that have been in D7. I miss a settings we had in D7 and i am not able to add a dependency without additional settings. I don't depend on Features if there is another way of doing things like this in D8.

What am i missing in D8? What would be the current workflow to get such environment dependent settings and modules active and different environments in Drupal 8?

Thanks for you help!
Drupal 7

Have you considered adding some intelligence to settings.php? You could test $_SERVER['HTTP_HOST'] there, and set $conf['some_variable'] accordingly. Below are some examples from Pantheon. They use their own environment variables to test which environment is running, but you can achieve the same by testing $_SERVER['HTTP_HOST'] or maybe testing file_exists('some_file_which_identifies_environment') - whatever is convenient.

// All Pantheon Environments.
if (defined('PANTHEON_ENVIRONMENT')) {
  // Drupal caching in test and live environments.
  if (in_array(PANTHEON_ENVIRONMENT, array('test', 'live'))) {
    // Anonymous caching - enabled.
    $conf['cache'] = 1;
    // Block caching - enabled.
    $conf['block_cache'] = 1;
    // Expiration of cached pages - 15 minutes.
    $conf['page_cache_maximum_age'] = 900;
    // Aggregate and compress CSS files in Drupal - on.
    $conf['preprocess_css'] = 1;
    // Aggregate JavaScript files in Drupal - on.
    $conf['preprocess_js'] = 1;
  }
  // Drupal caching on dev environment, and all multidevs
  else {
    // Anonymous caching.
    $conf['cache'] = 0;
    // Block caching - disabled.
    $conf['block_cache'] = 0;
    // Expiration of cached pages - none.
    $conf['page_cache_maximum_age'] = 0;
    // Aggregate and compress CSS files in Drupal - off.
    $conf['preprocess_css'] = 0;
    // Aggregate JavaScript files in Drupal - off.
    $conf['preprocess_js'] = 0;
  }

  // Minimum cache lifetime - always none.
  $conf['cache_lifetime'] = 0;
  // Cached page compression - always off.
  $conf['page_compression'] = 0;


  if (PANTHEON_ENVIRONMENT == 'dev') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-X';
  }
  else if (PANTHEON_ENVIRONMENT == 'test') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-Y';
  }
  else if (PANTHEON_ENVIRONMENT == 'live') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-Z';
  }
}




Drupal 8

The same approach can work in Drupal 8, except that the global configuration variable is named $config. This is documented here: Configuration override system and that page shows the example:

$config['system.maintenance']['message'] = 'Sorry, our site is down now.';