15

I have created different split for each environement (local, dev, test, prod) using the Configuration Split module. How can manage modules (enable/disable) in each environment?

Should I keep core.extensions.yml in each split and remove the module to be uninstalled from the list?

1 Answer 1

10

The core.extension.yml should only be put into the default, shared config. As it only holds those modules, that are enabled across all your different environments.

$config_directories['sync'] = '../config/sync/default/shared';

This default Drupal config sync directory also has the config_split.config_split.local.yml in it, which defines which modules apart from the ones in the core.extension.yml should be enabled additionally when the local split is active.

uuid: abc123456-7890-abcd-906d-abc123456
langcode: en
status: false
dependencies: {  }
id: local
label: Local
folder: ../config/sync/default/local
module:
  browsersync: 0
  devel: 0
  features_ui: 0
  field_ui: 0
  kint: 0
  link_css: 0
  masquerade: 0
  views_ui: 0
  webprofiler: 0
theme: {  }
blacklist: {  }
graylist: {  }
graylist_dependents: true
graylist_skip_equal: true
weight: 0

Then, inside each environment's settings.local.php you have to define which split in addition to the default, shared config should be active and which not. Here's how it may be configured on your local machine:

$config['config_split.config_split.local']['status'] = TRUE;
$config['config_split.config_split.dev']['status']   = FALSE;
$config['config_split.config_split.stage']['status'] = FALSE;
$config['config_split.config_split.prod']['status']  = FALSE;

The core.extension.yml only holds those modules that are shared among all your different environments.

3
  • This. It's critical to have every environment covered in your settings.php (or settings.local.php) like @leymannx has shown above. Some tutorials have shown where if production is set as the default configuration, a specific configuration split isn't needed, but in my tests, I haven't been able to get that to work.
    – karolus
    Commented Oct 8, 2018 at 19:25
  • 2
    When making changes to settings*php files and/or config like this. Remember to drush cache:rebuild if something isn't making sense. I often have to do this for config:import to pick up the changes I just made on disk. Even after that, I sometimes have to go to /admin/config/development/configuration/config-split to make sure the right environment is showing. And after a cache:rebuild even that page takes a reload (load up some cache?) to get the environment switched. Just play with it. Commented Aug 1, 2019 at 1:36
  • 1
    Took me a bit to figure out since I was trying to turn off a module from prod locally. The modules must be disabled in core.extension.yml and then you let config_split.config_split.prod.yml enable them. If you have them enabled in core.extension.yml it won't work as expected.
    – No Sssweat
    Commented Sep 28, 2023 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.