Got Features? Configuration Management in Drupal 8

Drupal 8Before Drupal 8, changes in site configuration could only be stored and moved between environments by using the Features module. This practice was less than ideal, as Features was not originally conceived for this purpose.

Since there was no better way to manage configuration outside of the database, this became the standard practice. Inspired by Features’ limitations and the need for a more reliable configuration management process, a Configuration Management Initiative (CMI) was established to devise a solution for Drupal 8 and beyond.

The initiative yielded the Configuration Manager module, a user interface for exporting and importing configuration changes between environments that are now integrated into D8 core. Now that we have a greater variety of options, let’s take a closer look at the best practices for configuration management in D8.

In theory, CM manages all configuration by exporting configuration from one environment and importing it into another, but in some situations, it cannot be that simple. The primary purpose for Features in D8 gets back to the original goal of the module which was to provide an interface for bundling functionality that logically belongs together such as a photo gallery, hence the name “Features.”

It’s still possible to manage configuration using Features, just as we did in Drupal 7 and before. There are some workflows involving multiple simultaneous developers that use a combination of Features in local sandbox environments and CM for conveying configuration betwixt servers.

And then there are overrides. These now reside in the $config variable array (formerly $conf) in a settings.php file. The array is also now organized in a way that is more in keeping with the new CM system (

[name of the YAML file][name of the configuration item] e.g. $config[‘’][‘name’] = ‘Overriding site name’;).

There are a few files in which configuration overrides can be placed:

  1. Possibly version controlled settings.php
  2. A non-version controlled (or gitignored) settings.local.php
  3. A version controlled settings_environment directory that contains files for each…you guessed it, environment.

The simplicity of the Configuration Management system in Drupal 8 is its strong suit, however, this comes at the expense of flexibility when there are multiple environments to manage. Managing configuration in Features could be advantageous because Features more clearly organizes configuration and allows custom code to reside along with its corresponding config.

Features is also a great solution when building install profiles for multisites and/or if rapid provisioning is needed. Although the stated goal of using a Features CM hybrid is to reduce conflicts, those conflicts could be avoided on the basis that different CM files contain configuration for different areas. Any conflicts that arise would be there regardless of CM or Features usage.

D8 Config Decision Tree

While the $config variable in settings.php is the most complex, it offers the greatest flexibility. If there is only one environment, it’s possible that configuration management is not necessary. Configuration that is common between environments and does not have security requirements can be placed in settings.php directly.

If there are multiple environments, it may be possible to distil them down into types of environments when considering configuration. For example, there could be a production environment type and a non-production type used for development, testing, and staging. Perhaps there is also a local sandbox type.

Any secure configuration can be placed in a file that is not version controlled, so it will not be in the repository. It is manually placed in each environment and named settings.local.php. This file is included in the settings.php file. One advantage to having this outside of version control is that configuration changes don’t always happen at the same time as deployments.

Finally, there are the settings.environment.php files that reside in a version controlled settings_environment directory. These should be used if access to all servers is not available or if there is a lot of environment specific configuration.

There’s no one way to manage configuration. It depends on the type of environment(s), configuration, custom code, server access, and security needs.

The overall guiding principles are:

  • Keep It Simple and use Drupal 8 Configuration Management
  • Add Features, settings.php, settings.local.php, and settings.environment.php only if justified.

The key is to understand your needs and identify the right strategy for each project. We’d love to hear your thoughts about and experience with configuration management in Drupal 8. Please share in the comments below.

2017-03-31T06:19:53+00:00 Categories: Drupal, Drupal 8|

About the Author:

Dan joined CivicActions as an engineer in 2015, serving as front and backend developer with a passion for open source software. He is a Drupal generalist since 2008 and agile evangelist who is driven to make things work more efficiently.

With more than a decade of media production experience, primarily in the media and higher education verticals, Dan brings a knack for persistence and collaboration that makes him a valuable team player in the creation of compelling sites for clients. His love for learning new technologies keeps him on the watch for tools that make things work better.

Before joining CivicActions, Dan served as product owner for National Public Radio’s Core Publisher Drupal multisite. This facilitates member stations’ ability to share digital content throughout the network the same way they share audio content. Dan was also instrumental in building a Site Factory for Harvard Medical School (HMS) departments and laboratories, simplifying maintenance and enhancement production. He pioneered the adoption of Agile processes for his team at HMS, still used there as an indispensable tool for successful projects.

Dan holds a BA in classical guitar from John Hopkins University and enjoys playing a multidimensional array of plucked string and percussion instruments. Outside of work, Dan is a proponent of environmental sustainability and enthusiastic cyclist, swimmer, and cross-country skier — depending on the weather. He also enjoys local food with his family in the mountains of North Carolina.