Skip to content

Latest commit

 

History

History
105 lines (76 loc) · 8.21 KB

drupal-8-configuration-management.md

File metadata and controls

105 lines (76 loc) · 8.21 KB
title description tags categories
Configuration Workflow for Drupal 8 Sites
Configure your Drupal site's performance and caching settings to make significant improvements.
devdrush
workflow
drupal8

Managing configuration is an extremely important part of any team website project, but in many cases, this area of the project does not receive as much attention as it deserves. The tools for Drupal 7 do not provide complete coverage of all configuration settings, leading to inconsistencies in configuration handling and inconvenient workarounds. This has led to configuration management becoming a real thorn in the side for many projects.

Pantheon supports the Drupal 8 Configuration Management system and defaults configuration into the sites/default/config directory for each Pantheon Drupal 8 site. You can export your configuration into that directory directly using Drush's config-export command or indirectly using Drupal's UI to download the configuration and then use SFTP/Git to place the configuration in sites/default/config. For more information on how this all works, check out Matt Cheney and David Strauss' presentation on Drupal 8 CMI on Managed Workflow at Drupalcon Amsterdam.

Watch: Configuration Management in Drupal

<script src="//fast.wistia.com/embed/medias/oczdbaylm0.jsonp" async></script><script src="//fast.wistia.com/assets/external/E-v1.js" async></script>
 

Basic Workflow

  1. With the Development environment in SFTP mode, export your configuration to code:

    drush cex -y
    
  2. Return to the Dashboard and commit the configuration changes.

  3. Deploy the code to Test.

  4. Import the configuration from code into the test environment database:

    drush cim -y
    
  5. Test the site.

  6. Deploy the code to Live.

  7. Import the configuration from code into the live environment database:

    drush cim -y
    
  8. Profit.

Using Terminus, you can complete the above process from the command line.

Workflow Example

  1. terminus drush <site>.dev -- cex -y
  2. terminus env:commit <site>.dev --message="Export configuration to code"
  3. terminus env:deploy <site>.test --sync-content --cc --updatedb --note="Deploy configuration to test"
  4. terminus drush <site>.<env> -- cim -y
  5. open https://test-mysite.pantheonsite.io
  6. terminus env:deploy <site>.live --cc --note="Deploy configuration to live"
  7. terminus drush <site>.live -- cim -y
  8. open live-mysite.pantheonsite.io

Configuration Tools for Drupal 8

With Drupal 8, much more powerful tools promise to greatly improve this situation. The new configuration management system provides complete and consistent import and export of all configuration settings, and Git already provides facilities for managing parallel work on different branches. When conflicts occur, it is possible to back out the conflicting changes, take just the version provided in the central repository, or use three-way merge tools such as kdiff3 to examine and manually resolve each difference. A new Drush project, config-extra, includes a config-merge command that streamlines the use of these tools.

Config Direct Save Module

If you prefer to use a GUI to manage configuration management, try the Config Direct Save Module, available on Drupal.org. Activating this module creates a new Update menu option under your configuration menu. This module can make backups of configurations (when you check the backup check box) and override the sync (all files with old configuration) by the new configurations (replace all configurations files).

Drush Config Workflow

Even with tools, a project needs to make a plan to manage the configuration workflow. To help projects get started, Pantheon has set up a public repository called Drush Config Workflow. This repository contains documentation on a couple of different configuration workflows that can be used during different phases of a project.

Git Configuration

The Git configuration workflow describes how to use config-merge to export your configuration changes, commit them to Git, push them to the central repository, pull the changes locally, and then merge them with your local development site’s configuration. All of this is done in a single command.

rsync Configuration

The rsync configuration workflow allows you to use a similar workflow in situations where you cannot make commits on the remote Drupal site. In these instances, config-merge will export changes to a temporary directory and then rsync them to the local system, where they are committed to a temporary branch in Git and then merged with the local configuration changes.

Three-way Merge

Additionally, the three-way merge page in this repository describes what to do when the config-merge tool encounters a conflict, and brings up a three-way merge tool such as kdiff3. This tool can considerably reduce the time needed to comprehend and resolve merge conflicts.

MySQL Credentials

Installation Script

If you would like to try out any of the example scenarios presented in the repository, there is also a handy installation script that will quickly set up a local environment for you to use. It can be used to either clone a Pantheon site locally, or it can create both sites locally. Instructions on how to use the script are detailed on the installation page.

Relocated Configuration Directory

Configuration files can contain sensitive information. Drupal takes some measures to protect the default configuration directory, but the conventional way to secure these files is to locate them outside of the document root so they are not web accessible. Following this convention may help make site configuration easier to manage.

Before you Begin

Configure and Relocate

After implementing a nested docroot, set a new path (/config) for configuration directories by adding the following to settings.php:

/**
 * Place the config directory outside of the Drupal root.
 */
$config_directories = array(
  CONFIG_SYNC_DIRECTORY => dirname(DRUPAL_ROOT) . '/config',
);

Note

Care should be taken to ensure that this code is added after the `settings.pantheon.php` is included; otherwise, the `CONFIG_SYNC_DIRECTORY` will be overwritten with the Pantheon default value. The configuration directory must exist before this variable is changed.

Relocate the configuration directory for the default location using git mv:

$ git mv web/sites/default/files/config .

For additional details, see this blog post by Greg Anderson.