Advanced Drupal 8 Configuration Management (CMI) Workflows - Liip

  • Автор темы Planet PHP
  • Дата начала

Planet PHP

Guest
After implementing some larger enterprise Drupal 8 websites, I would like to share some insights, how to solve common issues in the deployment workflow with Drupal 8 CMI.

Introduction to Drupal CMI


First of all, you need to understand, how the configuration management in Drupal 8 works. CMI allows you to export all configurations and its dependencies from the database into yml text files. To make sure, you never end up in an inconsistent state, CMI always exports everything. By default, you cannot exclude certain configurations.

Example:


If you change some configuration on the live database, these configurations will be reverted in the next deployment when you use


drush config-import


This is helpful and will make sure, you have the same configuration on all your systems.

How can I have different configurations on local / stage / live environments?


Sometimes, you want to have different configurations on your environments. For example, we have installed a “devel” module only on our local environment but we want to have it disabled on the live environment.


This can be achieved by using the configuration split module: https://www.drupal.org/project/config_split

What does Configuration Split?


This module slightly modifies the CMI by implementing a Config Filter (https://www.drupal.org/project/config_filter). Importing and exporting works the same way as before, except some configuration is read from and written to different directories. Importing configuration still removes configuration not present in the files. Thus, the robustness and predictability of the configuration management remains. And the best thing is: You still can use the same drush commands if you have at least Drush 8.1.10 installed.

Configuration Split Example / Installation Guide


Install config_split using composer. You need need at least “8.x-1.0-beta4” and > drush 8.1.10 for this guide.


composer require drupal/config_split "^1.0"


Enable config_split and navigate to “admin/config/development/configuration/config-split”


drush en config_split -y


Optional: Installing the chosen module will make the selection of blacklists / greylists way more easier. You can enable chosen only on admin pages.


composer require drupal/chosen "^1.0"


I recommend you to create an “environments” subfolder in your config folder. Inside this folder you will have a separate directory for every environment:



Now you can configure your environments:



The most important thing is, that you set every environment to “Inactive”. We will later activate them according to the environment via settings.php



Here is my example where I enable the devel module on local:



Activate the environments via settings.php


This is the most important part of the whole setup up. Normally, we never

Truncated by Planet PHP, read more at the original (another 5477 bytes)

Читать дальше...
 
Сверху