Using version control to keep track of configuration changes
Inside this config
directory, there are two more directories: active
and staging
. Both contain no configuration files by default, but they each contain a helpful README.txt
.
The contents of the active
directory's README.txt
are as follows:
If you change the configuration system to use file storage instead of the database for the active Drupal site configuration, this directory will contain the active configuration. By default, this directory will be empty. If you are using files to store the active configuration, and you want to move it between environments, files from this directory should be placed in the staging directory on the target server. To make this configuration active, visit admin/config/development/configuration/sync
on the target server. For information about how to deploy configuration between servers, see http://drupal.org/documentation/administer/config.
The staging
directory's README.txt
explains the following points:
In order to start using Configuration Management to keep track of your configuration changes, all you have to do is export your current configuration and place it inside the staging
directory as follows:
- Go to
/admin/config/development/configuration/full/export
and use the Export button to download an archive of your site configuration, as shown in the following screenshot: - Save the archive inside the
sites/default/files/config_HASH/staging
folder of your Drupal source files and extract the contents of the archive. The result should look something like this:Tip
If you're familiar with the Drupal command-line tool Drush, you can export configuration with a simple command. Check Chapter 9, Useful Tools and Getting Help for details.
You can find more detailed information in the next chapter, Chapter 2, Configuration Management for Administrators.
Types of configuration
There are two types of configuration in Drupal 8: simple configuration and configuration entities.
Simple configuration is basically the same as variables (that is, the site name or the number of nodes on the front page) and is used for single global settings.
Looking at the system module's configuration file system.site.yml
, you see some examples for simple configuration. The file defines the default values for some of the main settings you will need on your site—that is, the site name or the default e-mail address:
name: 'Configuration Management in Drupal 8' mail: 'info@example.com' slogan: '' page: 403: '' 404: '' front: user langcode: en
As you can see, configuration can even be nested, so you can group settings.
Configuration entities are more complex than a simple configuration, and are used for objects that can have multiple copies such as content types or views.
Configuration storage and deploying between environments
Earlier in this chapter, we learned about the directory named staging
. In this directory, you put the configuration you would like to import into a copy of your Drupal site—for example, to copy changes from your local environment to your production site. Simply export the new configuration from your local environment, place it in the staging directory of your production site (preferably by using version control), and import it later at admin/config/development/configuration/sync
.
Note that, at the time of writing this book, the active
directory is not used as originally intended. Its original purpose was to store the site's currently active configuration but, since that is now kept in the database, the active
directory remains empty. This might change in future versions of Drupal 8.