Drupal Configuration Export with Config Split Module

This guide explains how to manage and export Drupal configurations using the Config Split module for different environments.

1. Install Config Split Module

First, install the Config Split module using Composer:

composer require drupal/config_split

2. Enable Config Split Module

Enable the module using Drush:

drush en config_split -y

3. Configure Config Split

Navigate to Admin > Configuration > Development > Config Split and create splits for each environment (e.g., Development, Staging, Production). Specify the directories where the configurations for each environment should be stored.

Example Configuration for Development Split

4. Export Configuration

Use Drush to export the configuration for the specific environment:

# Export configuration for Development
drush csex config_split.config_split.development

# Export configuration for Staging
drush csex config_split.config_split.staging

# Export configuration for Production
drush csex config_split.config_split.production

5. Commit Configuration

Commit the exported configuration to your version control system:

# Example for Development Environment
git add config/dev
git commit -m "Exported Drupal configuration for development using Config Split"
git push origin main

6. Pull Configuration

Pull the latest changes from your version control system on the target environment:

git pull origin main

7. Import Configuration

Use Drush to import the configuration for the specific environment:

# Import configuration for Development
drush csim config_split.config_split.development

# Import configuration for Staging
drush csim config_split.config_split.staging

# Import configuration for Production
drush csim config_split.config_split.production

8. Clear Cache

Clear the cache after importing configuration changes:

drush cr

Workflow Summary

  1. Install and enable the Config Split module.
  2. Configure splits for each environment in the Drupal admin interface.
  3. Export the configuration for the specific environment using Drush.
  4. Commit the exported configuration to your version control system.
  5. Pull the latest configuration changes on the target environment.
  6. Import the configuration for the specific environment using Drush.
  7. Clear the cache to ensure the changes take effect.

Setting Environment Variables

Ensure that the environment-specific configurations are correctly set in your web server configuration or in an .htaccess file.

Apache example:

SetEnv DRUPAL_ENV dev

Nginx example:

env DRUPAL_ENV=dev;

By using the Config Split module, you can manage environment-specific configurations more effectively, ensuring that each environment has the correct settings.

Published By: Krishanu Jadiya
Updated at: 2024-08-03 01:26:56

Card Image

How to Set Up a Local SSL Certificate on Apache: Step-by-Step Guide

Learn how to set up a local SSL certificate on Apache with this comprehensive step-by-step guide. Secure your local development environment with HTTPS.

Card Image

Latest Features of Coding Technology

Explore the latest features and advancements in coding technology, including new programming languages, frameworks, DevOps tools, AI integration, and more.

Card Image

Understanding Laravel Mix Webpack Configuration: Step-by-Step Guide

Step-by-step explanation of a Laravel Mix Webpack configuration file, including asset management for JavaScript, CSS, and Vue.js support.

Card Image

How Emojis Can Enhance Your Git Commits | Gitmoji Guide

Discover how to enhance your Git commits with emojis. Learn about the best practices for creating informative and visually distinctive commit messages.