What are the best practices to exclude modules from being installed in the next environment in #drupal 8/9/10 ?

By toswebdev, 14 May, 2022
What is the best practices to exclude module from being installed to the next environment?

Some modules are enabled by developers on the local instance of their drupal site but are not meant to be enabled on the production site.

Solution 1st:-

The manual solution to this is to uninstall the module before doing a configuration export and to manually install it again locally after a configuration import.

Solution 2nd:-

Enable the module and activate the filter by declaring $settings['config_exclude_modules'] in your settings.php file, eg:

$settings['config_exclude_modules'] = ['devel', 'stage_file_proxy'];

Now, when you export configuration (drush config-export), the selected modules should no longer show up in core.extension.yml and their configuration should not be exported.

Make sure first before doing that to remove this module from core.extensions.yml manually for the first time.

Update: It seems to be related to a drush issues: drush config: status does not respect excluded modules.


All comments go through moderation, so your comment won't display immediately.