Drupal 8 Style Configuration Management in Drupal 7

What is configuration management?

Content management systems allow administrators and developers to change settings in the User Interface (UI).

These settings, or configurations are stored in the database.

Exporting them to code allows us to manage them in version control for backups, and across servers for development and testing, without having to have the actual database.

Configuration management is moving things from the database to code.

Drupal 8 Configuration Management

  • Built from the ground up
  • Core and Contrib follow the same rules
  • Consistent YAML files for storing configs
  • Configs are imported from code to the database and...
  • Exported from the database to code
  • Can be "split" allowing for different config in different places (Dev, Stage, Prod)

Features - Drupal 7 Configuration Management

  • Features module allows you to export content into custom PHP modules
  • Clicked together exportables and variables (provided by the Strongarm module) from the UI
  • Built by the decisions of the developer, and maintained/modified by any other developer who came along after.

Enter Features Builder Contrib module

Save valuable time (and sanity) by bypassing the process of picking and choosing which components go into which Features.

Features Builder is a module that analyzes the build of your Drupal site and automatically builds Feature modules to capture the site's configuration.

How does it work?

The main functionality is built around the idea of a "builder" which is responsible for identifying what configuration it's responsible for.

Various administrative screens allow you to see what's available on your site, how the builders will package your configuration, and one-click operation to generate and install the Features modules.

Don't like the Builders?

Build your own builders!

hook_features_builders_info() hook_features_builders_info_alter() hook_features_builder_components_FEATURE_alter()

Migrating to Features Builder from a click-together-workflow

  • It is not easy!
  • It is not hard!

The great revert!

Drupal 7 to work from the code in the features modules, configuration in the database, or both.

The Features revert drush fra would allow you to say ignore the database, and use code, but would not empty the database.

drush fra --force would force the emptying of the database, so it would have to use the code.

Unlike Drupal 8 configuration which in which config is imported/exported from the database.

The tedium of manually rebuilding

Once you have the database empty, and the functionality in code, you can turn off the feature, rebuild the functionality, so it can be exported later.

The Build

drush fb -y

The deploy and revert

After you deploy, add drush fra -y --force to your CI or run it manually.

Special thanks to Damon, Morgan, Savino, Adam, Shiraz, and Matthew for the photography!

The End

Continuing the conversation: