Skip to main content

Configuration deployment in Drupal 8

Best practices how to deploy Drupal 8 configuration from one website to another.

There are 3 possible ways how you can deploy configuration changes from development environment to your production website.
I will explain step by step with good and bad things for certain solution.

 

1. Drupal core Configuration synchronization

Configuration can be exported from website using Configuration synchronization. This is core option in Drupal 8.

You can use this solution if you go to Configuration -> Development -> Configuration synchronization on your website. Then you go to tab Export and then to subtab Single item and choose what you want to export.

Single item export

You need to copy your configuration and to import (same page but Import tab, subtab Single item) it to website you want.

Good: You can synchronize only things you want. You do not need to synchronize some stuff that other solutions force you to install.

Bad: You need to know what you are working. You need to have some experience to know what you need to export. For example if you want to export content type, you should know that you need to export content type, fields, field storage, etc.

 

2. Configuration synchronization using Drush

If you want to use this option you need to have Drush installed on your server.

To export whole website configuration use this command

drush cex

Whole configuration will be exported to config/sync folder in the root of your website. Copy this files to same folder on another website and import with

drush cim

Good: This solution is the best for newbies. With this solution you export / import whole website configuration.

Bad: This solution exports / imports things you want and things you do not want. If you want to exclude something you need to delete that .yml file before importing.

 

3. Synchronization using Features module

For this you will need Features module. After you installed it, go to Configuration -> Development -> Features on your website and Create new feature.

Features export

Two important fields are Bundle and Path.
Bundle you can use to collect together groups of features.
Path is location where your feature will be exported.

When you choose something to export, all other configurations that have dependency will be automatically checked. In this case I checked Basic page content type.

Features export

After your feature is created it will be listed in Features list. If something is changed on website in configuration that feature will have state Changed.

Features list

Features can be imported like any other .yml I was writing before (Single import, Drush command, ...).

Good: Features are good solution for newbies and for experienced users because of automatically selection of dependencies. No garbage exported. Easy to use.

Bad: none