This guide explains how to manage and export Drupal configurations using the Config Split module for different environments.
First, install the Config Split module using Composer:
composer require drupal/config_split
Enable the module using Drush:
drush en config_split -y
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.
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
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
Pull the latest changes from your version control system on the target environment:
git pull origin main
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
Clear the cache after importing configuration changes:
drush cr
Ensure that the environment-specific configurations are correctly set in your web server configuration or in an .htaccess
file.
SetEnv DRUPAL_ENV dev
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