How to Manage Environment-Specific Drupal Modules with Configuration Split

In Drupal, developers want tools like devel, views_ui, and stage_file_proxy enabled locally, while production must keep them uninstalled for security and performance. If you simply enable devel locally and run drush cex, Drupal writes devel into core.extension.yml—and the next production drush cim enables it on your live site. Because Drupal’s settings.php configuration override system cannot enable or disable modules, Configuration Split (config_split) is the standard way to separate environment-specific configuration cleanly.

Editorial illustration of Drupal Configuration Split directories across local, staging, and production

Editorial illustration: keep shared configuration in config/sync and isolate local development modules in config/splits/local.

Summary

  • Drupal’s settings.php $config[...] overrides cannot enable or disable modules; Configuration Split solves this by splitting environment-specific modules and YAML files out of config/sync.
  • Use Complete Split when a module and all of its configuration should exist only in specific environments (such as devel or stage_file_proxy in local/dev).
  • Control which split is active per environment in settings.php or settings.local.php ($config['config_split.config_split.local']['status'] = TRUE;) so production keeps dev splits disabled.
  • Always preview changes with drush cst or drush cim --dry-run before importing configuration on staging or production.

Why settings.php overrides cannot replace Configuration Split

Drupal’s configuration override system works well for changing a site name, disabling email sending, or swapping an API endpoint in settings.local.php. However, as explained in the Drupal Configuration Split Complete Split documentation, you cannot use configuration overrides to enable or disable modules.

Module installation state lives in core.extension.yml and triggers install/uninstall hooks, database schema changes, and service container rebuilds. Configuration Split bridges that gap by hooking into Drupal’s config export and import pipeline:

  • When exporting (drush cex) with a split active, Config Split removes the split’s modules and config files from your main config/sync directory and writes them into a dedicated split folder (for example, ../config/splits/local).
  • When importing (drush cim) on production where that split’s status is FALSE, Drupal imports only config/sync—ensuring devel stays uninstalled on production even if every developer uses it locally.

Complete Split vs. Conditional Split: Which one do you need?

Configuration Split offers two mechanisms, and choosing the right one prevents confusing diffs:

  1. Complete Split: Completely removes selected modules (and all configuration owned by or depending on them) from config/sync and places them in the split directory. Use this for devel, kint, stage_file_proxy, views_ui, or dblog (if disabled on prod).
  2. Conditional / Partial Split (or graylist/partial behavior depending on module version): Keeps a base configuration in config/sync while allowing an environment split to override specific settings. Use this only when the module itself is enabled everywhere, but one environment needs different exported YAML values—though for simple values like API URLs, $config overrides in settings.php are often simpler.

Step-by-step: Set up a local development split

1. Install config_split via Composer

Enable the Configuration Split module across all environments so Drupal’s import/export pipeline understands your split definitions everywhere:

composer require drupal/config_split
drush en config_split -y

2. Create the split directory outside the web root

Place your split folder alongside config/sync, never inside web/sites/default/files:

config/
  sync/
  splits/
    local/

3. Configure the local split entity

In the Drupal admin UI (Configuration > Development > Configuration Split), create a split named local:

  • Folder: ../config/splits/local
  • Status: Unchecked (FALSE) by default in exported config! That way, production never accidentally activates it.
  • Complete Split > Modules: Select devel, stage_file_proxy, views_ui, and any other local-only tools.

4. Activate the split only in settings.local.php

In your untracked local settings.local.php (never committed to production), force the local split on:

$config['config_split.config_split.local']['status'] = TRUE;

In production settings.php, explicitly set it to FALSE (or rely on the exported default being FALSE):

$config['config_split.config_split.local']['status'] = FALSE;

5. Export and verify the diff

Run drush cex locally. Inspect git status and git diff carefully:

  • config/sync/core.extension.yml should not contain devel or stage_file_proxy.
  • config/splits/local/ should contain core.extension / split files for those dev modules.
  • config/sync/config_split.config_split.local.yml should have status: false.

Before deploying to production, test the full import on a staging copy—using a sanitized database if you pulled production data, as covered in how to sanitize a Drupal staging database—and always follow a safe Drupal config import review checklist.

Common mistakes

  • Leaving status: true in the exported config_split.config_split.local.yml. If you forget to disable the split by default and override it only in settings.local.php, production will install your dev modules on the next drush cim.
  • Forgetting to include dependent config in the split. If a View or Block depends on a dev-only module, make sure it is split cleanly or drush cim on production will fail with a missing module dependency error.
  • Running drush cex on production or mixing manual UI edits. Keep one predictable source of truth: export from local, commit YAML, and import on staging and production. If you also run edge/render caching, verify post-deploy behavior with Drupal cache tag debugging.

Why this matters

Manual config editing—deleting devel lines from core.extension.yml before every commit—is error-prone and slows down team workflows. Configuration Split lets developers keep their full local debugging toolkit while guaranteeing that drush cim on production stays deterministic and safe.

My Take

Keep your splits minimal. Most Drupal sites only need one local split (for devel, views_ui, and stage_file_proxy) and maybe a prod split if you run production-only logging or caching modules. Put simple secrets and environment URLs in settings.php overrides or environment variables rather than creating five overlapping splits that nobody remembers how to debug six months later.

Conclusion

Install drupal/config_split, keep your local split disabled (status: false) in config/sync, enable it exclusively in settings.local.php, and verify git diff after every drush cex so development tools never leak into production deployments.

Sources