Config Split Reference
Drupal Config Split lets you have different configurations for different environments (local, staging, production, etc.) while sharing a common base.
How It Works
🍕 Pizza Analogy
Default config (config/default/) = Base pizza everyone getsSplit configs (
config/envs/*/) = Toppings per environment
local→ Local/Docker Solr settingsstaging→ Staging server settingsproduction→ Production Solr cluster settings
Directory Structure
config/
├── default/ # Base config (shared by all)
│ ├── search_api.server.*.yml
│ └── ...
└── envs/
├── local/ # Local/Docker overrides
├── staging/ # Staging overrides
└── production/ # Production overrides
├── search_api.server.my_solr.yml
└── config_split.patch.*.yml
Export Configuration
To save current Drupal config to a split's yml files:
# Set environment variable inline (bypasses settings.php override)
DRUPAL_ENV=production drush config-split:export production
Import Configuration
To apply a split's yml files to Drupal:
# Import only the split configs (recommended)
DRUPAL_ENV=production drush config-split:import production
# Or import ALL config (default + split combined)
DRUPAL_ENV=production drush config:import
Check Active Split
# See which splits are active
drush config:get config_split.config_split.production status
# List all splits and their status
drush config-split:status-override
Activate via Environment Variable
Set an environment variable to auto-activate a split (configure in settings.php):
# Inline (for single command)
DRUPAL_ENV=production drush <command>
# In Apache vhost
SetEnv DRUPAL_ENV production
# Or export in shell session
export DRUPAL_ENV=production
⚠️ Settings.php Override
If settings.php hardcodes $config['config_split...']['status'] = FALSE,
state overrides won't work. Always use the environment variable method instead.
Common Config Split Tasks
Create a New Split
- Create the split in Drupal: Admin → Config → Development → Config Split
- Create the directory:
mkdir config/envs/my_split - Add the split to
settings.phpactivation logic - Export:
DRUPAL_ENV=my_split drush config-split:export my_split
Update Split After UI Changes
After making changes in Drupal UI that you want saved to the split:
DRUPAL_ENV=production drush config-split:export production
Deploy Split to Another Server
- Copy the yml files to the other server's
config/envs/ - Set the environment variable
- Import:
DRUPAL_ENV=production drush config-split:import production
Example settings.php
Add environment-based split activation to settings.php:
// Disable all splits by default
$config['config_split.config_split.local']['status'] = FALSE;
$config['config_split.config_split.staging']['status'] = FALSE;
$config['config_split.config_split.production']['status'] = FALSE;
// Activate based on environment variable
$env = getenv('DRUPAL_ENV') ?: 'local';
switch ($env) {
case 'production':
$config['config_split.config_split.production']['status'] = TRUE;
break;
case 'staging':
$config['config_split.config_split.staging']['status'] = TRUE;
break;
default:
$config['config_split.config_split.local']['status'] = TRUE;
break;
}