Config Management

in

Drupal 8

It's in core

You don't need any module

 

DRUPALROOT/sites/default/files/configR@ND0M#H@$H#SALT

$settings['config_sync_directory'] = '../config/sync';

Managing config between sites

  • Sync site uuid ( universally unique ID )
  • Get config from one site ( dev site )
  • Set config to another site ( stage site )

Querying config schema using drush 

drush cim

drush cex

drush cli

drush cget config.key

drush cset config.key config_value

For Drush 9.x
drush cst

drush config:status

Override config schema in settings.php

  • Get config schema set
  • Get config schema set key
  • Create an entry in settings.php file to override
     
$config['config.prefix']['keyvalue'] = NEW_VALUE

To exclude some module's config from config sync

 

$settings['config_exclude_modules'] = ['module1', 'module2'];

Configuration interdependencies

Config is dependent on Content

Content is dependent on Config

Pull and import

You may use content_sync module or hook_update/install to create content

Chicken egg problem

Config split module

Lets you partition the config changes as per the development environment

drupal/config_filter, drupal/config_split

path/to/our/site_repo
+-- config
|   +-- development  # New directory for the split
|   +-- sync
+-- docroot
    +-- core
    +-- index.php

Add configuration for config split

Config split module

drupal/config_filter, drupal/config_split

Complete split

Conditional split

the_split_name is machine name of the split we created earlier.

$config['config_split.config_split.the_split_name']['status'] = TRUE;

complete moves the config in

new split folder

Contextual split the new split folder for finer tuning

drush config-split-export the_split_name
drush config-split-import the_split_name

Demo

?

Config

By Swastik Pareek

Config

  • 529