The following article are notes taken from the excellent presentation given by Michael Anello from DrupalEasy at DrupalCamp Colorado 2018.

Drupal's 8 configuration system provides a mechanism to export configuration from the database into code (.yml files).

Drupal 8 configuration system diagram

Syncing config needs to be part of our development process.

  • We're used to using "git pull".
  • We need to add "drush config-import".
  • We're used to using "git add/commit/push".
  • We need to add "drush config-export".

Updating codebase

  • git pull --rebase
  • drush config-import

Change branches

  • git checkout
  • drush config-import

End a task

  • drush config-export
  • git add
  • git commit
  • git push

The location of the imported configuration files is typically called the "sync" directory.
- Configured in settings.php file


(Github drupal-composer/drupal-project ) This project creates de sync directory.

Configuration files have lots of interdependencies.

  • A standard Drupal install has over 170 configuration files.
  • Not recommended to export/import subsets.
  • All or nothing

In sync means the config in database matches the config in the yml files.

Tips and tricks # 1

  • When possible, use the Configuration Read-only mode on the live environment.
  • It's like traininig wheels for using the database configuration system.

Tips and tricks # 2

  • When configuration changes are made to a remote environment, review, export, and commit then to the repository as soon as possible.

Tips and tricks # 3

  • Before working in a local environment, ensure your local configuration is up-to-date and in sync.

Tips and tricks # 4

  • When working with multiple branches in a local environment.
  • -- Be sure to export and commit configuration prior to changing branches.
  • -- Be sure to import configuration inmediatly after changing branches.

Tips and tricks # 5

  • When writing a commit message for a commit that includes updated configuration, it's a good idea to include the word "config" somewhere to let others know that they should probably do a "config-import".

Tips and tricks # 6

  • In most cases, the yellow warning text on the "Configuration Synchronization" page is less-than-helpful. It's probably best to ignore an focus on the "changed", "removed", and "new" section below it.

A recording version of Mike's presentation can be found here.

Addendum

$config_directories = array(CONFIG_SYNC_DIRECTORY => '../config/sync');

https://www.isovera.com/blog/practical-guide-configuration-management-drupal-8