Configuration Management in Drupal

Drupal's configuration management system allows developers to export, import, and synchronize configuration changes across environments, ensuring consistency, allowing the use of version control, and easy deployment.

This course covers the basics of the configuration system, setting up and securing the configuration sync directory, and creating clones of Drupal sites for development and testing. Learners will also explore various methods for synchronizing configuration, including using the UI and Drush, and understand the complexities of configuration interdependencies. Additionally, the course will delve into advanced topics such as overriding configuration, using Config Split for environment-specific settings, and automating configuration deployment.

Key topics

  • Overview of the configuration system
  • The configuration sync directory and security
  • Cloning sites for configuration management via both the command-line and the UI
  • Methods for synchronizing configuration changes across environments
  • Inspecting and managing configuration data with Drush
  • Managing configuration between live and local environments
  • Managing configuration dependencies
  • Techniques for overriding configuration settings
  • Using Config Split to manage environment-specific configuration settings
  • Automating configuration Deployment
Tutorials in this course
Categories
Drupal 8, 9, 10, and 11
More information

Drupal's configuration system helps to solve the problem of moving changes in configuration from development to production. It does this in two ways: by providing a unified way to store configuration and by providing a process by which configuration changes can be imported and exported between instances of the same site. The configuration system is the result of work completed within the Configuration Management Initiative (CMI).

In this introduction, we'll provide:

  • An overview of Drupal's configuration system
  • Key concepts that you should know about
Categories
Drupal 8, 9, 10, and 11
More information

Before we start synchronizing configuration, let's take a look at the default, out-of-the-box file location for staging and synchronizing configuration. Then we'll walk through how to change that directory to a location outside our project's docroot and update settings.php appropriately.

In this tutorial, we'll cover:

  • The default location of the configuration sync directory
  • How the configuration sync directory is secured
  • How to change the location of the sync directory
Categories
Drupal 8, 9, 10, and 11
More information

Before you can get started synchronizing configuration between instances of your site, you'll need to create a new instance or "clone" of your Drupal site.

By the end of this tutorial, you should know:

  • Why it's necessary to clone your site if you want to manage configuration between environments
  • How to find your site's universally unique identifier (UUID)
  • What to consider when setting up a directory structure for your project
  • How to clone a Drupal site
Categories
Drupal 8, 9, 10, and 11
More information

The configuration system in Drupal was designed to manage and sync configuration between instances of a Drupal site. So before configuration management can be useful, we must have another instance—or clone—of our Drupal site. In this lesson, you will learn:

  • Why cloning a Drupal site is necessary in order to manage configuration
  • How to clone a Drupal site using tools that have a graphical user interface (GUI)

If you prefer using web-based or GUI tools rather than command line tools such as Drush and Git, then this lesson is for you.

More information

The Configuration Manager module gives you as an administrator the ability to import and export configuration items on different instances of a Drupal site using a graphical user interface. In this tutorial, we'll take a tour of the Configuration Manager and the administrative interface it provides.

By the end of this lesson you will be able to:

  • Access administrative pages for Import, Export, and Synchronize
  • Find and configure permissions for Configuration Manager
  • Identify the 3 primary actions of configuration management and how to perform them using the UI
More information

While the administrative UI for Configuration synchronization certainly provides a simple and effective means to export and import configuration, it is by no means the preferred method. The Drush command line utility provides the same functionality without the need for a web interface or the need to log in.

Categories
Drupal 8, 9, 10, and 11
More information

There are some administrative UI tools for managing configuration, but some tasks can only be completed with Drush. As a site administrator, you will find Drush an indispensable tool for managing configuration between instances of the same site. Furthermore, Drush includes integration with Git in certain commands, enabling you to create a configuration workflow with Drush that also uses best practices in version control.

By the end of this lesson you should be able to:

  • Get the status of a site's configuration
  • List configuration on a site
  • View configuration objects
  • Set values for a specific key inside a configuration object
  • Edit a configuration object in active configuration without needing a configuration form
  • Integrate a Git workflow with Drush
More information

Using Drush to work with the Drupal Configuration System is straightforward when working locally. Navigate to the directory containing your site, then issue whatever Drush command you need.

Things become more complicated when multiple environments become involved. Often, a configuration change will need to be made on the production ("live") site and then need to be persisted to a Git repository later. When this occurs, Drush once more provides a solution in the form of the config-pull subcommand.

Note: Drush 8 and the latest version use different methods and file types for configuration files. This tutorial will demonstrate methods that are compatible with the latest version of Drush with notes related to Drush 8.

Categories
Drupal 8, 9, 10, and 11
More information

Drupal creates a line of separation between what is content and what is configuration. The line is such that content is stored only in the database, whereas configuration is maintained by the configuration management system. While cached to the database for performance reasons, configuration can be thought of primarily living in the sync directory as a series of flat files.

This sounds like a perfectly clear distinction in theory, but there are several times where interdependencies appear between content and configuration. Understanding the key places where these interface can help prevent confusion and "disappearing" settings due to a lack of understanding.

Categories
Drupal 8, 9, 10, and 11
More information

Not every environment or copy of a site you may be working on will be created equally. You may want to enable logging on a development site or need to use different API keys depending on the environment. But you also need to make sure that your instance-specific configuration overrides don't make it into the database, mistakenly get exported, or compromise security.

In this tutorial, you will learn how to:

  • Override the global $config array in settings.php (or settings.local.php)
  • Retrieve overridden (immutable) configuration (read-only mode)
  • Retrieve original (mutable) configuration for updating (read/write mode)
  • Set dynamic values for configuration instead of overriding values
Categories
Drupal 8, 9, 10, and 11
More information

Modules like Devel or Stage File Proxy offer key advantages when developing locally, but should never be enabled on a production site. This poses a problem for Drupal as which modules are enabled is a configuration. Compounding this problem is the configuration provided by these modules, as well as key configuration that must be set differently locally compared to production.

Fortunately, the Configuration Split module provides a means to accomplish all of these goals. Once set up, configuration can be exported in one or more "splits", enabling you to target different configurations for different environments or situations.

More information

When automating the deployment of a Drupal site, it's critical to have a good understanding of the configuration management workflow in order for deployments to be consistent and successful.

More information

When working on configuration in a module, whether as part of a migration that uses Migrate Plus configuration entities, or while developing custom configuration entities, you'll often need to re-import the configuration stored in the .yml files of the modules config/install/ or config/optional/ directories. This is tricky though, because Drupal only reads in those default configuration settings when the module is first enabled. So any changes you make to those files after the module has been installed will not be reflected without these workarounds.

Knowing how to do this can improve the developer experience of adding (or debugging) the default configuration that's provided with a module. Or for anyone using Migrate Plus configuration entities as part of a migration.

In this tutorial we'll:

  • Learn about the Configuration Development module
  • Look at how you can use Drush to perform a partial configuration import
  • Write an implementation of hook_uninstall() to remove a module's configuration when it's uninstalled

By the end of this tutorial you should be able to re-import the configuration provided by a module without having to uninstall and then reinstall the module.

This course appears in the following guides:
Module Development
We have the resources to get ready for Acquia Certification Exams.

Acquia Certified Drupal Developer Exam

Site Administration
Learn how to manage configuration, search, content workflows, performance, and more.

Drupal Site Administration