Split Configurations in Drupal 8
Blog

How to use Configuration Split Module to Split Configurations in Drupal 8

The configuration Split module allows users to define sets of configuration that will get exported to separate directories when exporting and get merged together when importing.

  • Drupal split module depends on Config Filter for the integration with the import/export pipeline of the Drupal UI and drush.

  • It is possible to define in settings.php which of these sets should be active and considered for the export and import

                                Here are a few things that are considered configuration:

Configuration split exposes a configuration entity which controls what you want to split off. Currently, you can

 

  • Blacklist modules: Any configuration that this drupal split module owns will automatically be blacklisted too.
  • Blacklist configuration: settings or configuration entities. These will be removed from the activesync directory.
  1.  Download and Enable Drupal configuration split module :- drush en config_split -y
  2.  Go to configuration  -> Configuration Split settings

Configuration Split Setting

  • Click on 'Add configuration split'. Naming is important, so we'll enter 'Dev split' as the name for this configuration. We'll also create a directory called 'sync-dev-split'. (where the config file will go from activesync directory)
  • Select Module’s from which configuration file (yml files ) will get split into another folder in root directory of your module .

Configuration Split Setting

  • There is an status Option which should be active (Checked)
  • Save

3. Doing exports and imports on dev or live .

From now on, if you want to import new settings whether it's on your dev or live environment, you can not use the drush core commands anymore. Use following commands: Go to Terminal 

A) Export your configuration in other folder

  • drush csex dev_split
  • sync-dev-split
  • Y/N option will be there =>Y
  • List of yml files => ls sync-dev-split
  • # to export on your dev environment ->    @dev:/home/drupal/drupal-core$ drush csex dev_split
  • # to export on your live environment ->     @live:/home/drupal/drupal-core$ drush csex live_split

B) Import Your configuration

  • In local -> drush csim dev_split
  • In dev site - drush @pantheon.config-split.dev csim dev_split
  • # to import on your dev environment ->    @dev:/home/drupal/drupal-core$ drush csim dev_split
  • # to import on your live environment ->    @live:/home/drupal/drupal-core$ drush csim live_split

                                                                                    OR

C) You can directly Import your Configuration

Go to Configuration-> Configuration Synchronization - If you have added multiple split config settings, then it will be shown like this in Configuration Synchronization

Synchronize Configuration Setting

There you can see Multiple Split configuration option like dev split & live Split

If you want to use “Dev split” go to your settings.php file

  • $config['config_split.config_split.dev_split']['status']= TRUE;
  • $config['config_split.config_split.live_split']['status']= False;
  • $config['config_split.config_split.test_split']['status']= False;

Result :

Synchronize Configuration Setting

References :