[Drupal] What are the changes in configuration rules for Drupal 8

| | 3 min read

We know Drupal 8 is the latest version of Drupal. It has lot's of difference from the previous version of Drupal. One of the major difference in Drupal 8 is in Configuration Management. In Drupal 7 there is version control system is used and for that there is different running site environments like staging, live etc are there. In Drupal 8 also have this environments but Drupal 8 comes with a file system-based configuration management system.

In Drupal 8 configuration Manager module provides a user interface for importing and exporting configuration changes between a Drupal installation in different environments, such as Production , Staging and Development, so we can make and verify changes with a comfortable distance from live environment. This allows to deploy a configuration from one environment to another,in the same site.

We know Drupal 8 uses the YAML (.yml) human-readable text file format to store configuration. Default configuration shipped with distributions, themes and modules are stored with the projects themselves in a config subdirectory. When the respective projects are enabled then these default configurations are imported into the active configuration store . So the active configuration store is the complete set of live configuration at any given time.

The active configuration files can be found by default at sites/default/files/config_XXXX/active.There is also a staging directory that Drupal uses to stage configuration changes, that on the same level. By default it will be empty and only populated when in the process of importing configuration.
Defining location of the configuration directories (active & staging) in the settings.php file during the installation Drupal.

$config_directories['active'] = 'sites/default/files/config_iND62oxf-4DyUHcbCA7mhupb_KEpUaGZ6qcfTnAscNQ/active';
$config_directories['staging'] = 'sites/default/files/config_iND62oxf-4DyUHcbCA7mhupb_KEpUaGZ6qcfTnAscNQ/staging';

By default these configuration folders are relative to the Drupal root installation folder. we can also override these locations in the same settings.php file.

$config_directories = array(
CONFIG_ACTIVE_DIRECTORY => '/var/www/d8/config/active', // outside the webroot
CONFIG_STAGING_DIRECTORY => '/var/www/d8/config/staging', // outside the webroot
);

Exporting,importing and synchronizing configuration
Making configuration changes on the live site is often not good idea. The goal of the configuration system in Drupal 8 is to make taking a copy of the site configuration easy to set up a development site where you make changes. Then importing those changes on the live site is also made simple. We can export, import and synchronize configuration in site via Manage > Configuration > Development > Configuration management (admin/config/development/configuration). It is possible to export a single configuration file and paste it into another environment. The single import option lets you specify the type of the configuration file and import it from your copy-pasted value.

Assume the there is identical dev and prod sites. Any changes made on the dev site will be saved into the active storage on the dev site. This can be exported and imported on the live site. The main thing is copy the YAML files into the staging directory. Once ran the import, the synchronize changes which will review all the changes between the staging and prod active directories. From the above, view the differences between each config files to ensure that the changes are as expected, before setting the changes active.

The Synchronize page will show removed or new config files. It is helpfull to check that there are no removals of any core config files (such as system.*, entity.*) as this will result in a site error. The Synchronization is done, then the staging directory contents are now elevated to the live configuration, new modules are enabled, content types, new fields etc. are added. In short all changes are live.

Reference:drupal.org