I want to be able to disable certain options of modules on non-production environments.

For example:

  • Disable XMLSitemap from running
  • Set "Read Only" mode for Search API indices to TRUE
  • Set robots.txt string to

    User-agent: *
    Disallow: /

How do you know whether you should override $config or $settings in settings.php?

Would it be:

$config['search_api.index.acquia_search_index']['readonly'] = TRUE;


$settings['search_api.index.acquia_search_index']['readonly'] = TRUE; 

Also, how can you confirm if these overrides are working? Is there an admin overview page that lists these things?

3 Answers 3


From settings.php, regarding $settings:


$settings contains environment-specific configuration, such as the files directory and reverse proxy address, and temporary configuration, such as security overrides.

@see \Drupal\Core\Site\Settings::get()

From settings.php regarding $config:

Configuration overrides.

To globally override specific configuration values for this site, set them here. You usually don't need to use this feature. This is useful in a configuration file for a vhost or directory, rather than the default settings.php. Note that any values you provide in these variable overrides will not be viewable from the Drupal administration interface. The administration interface displays the values stored in configuration so that you can stage changes to other environments that don't have the overrides.

There are particular configuration values that are risky to override. For example, overriding the list of installed modules in 'core.extension' is not supported as module install or uninstall has not occurred. Other examples include field storage configuration, because it has effects on database structure, and 'core.menu.static_menu_link_overrides' since this is cached in a way that is not config override aware. Also, note that changing configuration values in settings.php will not fire any of the configuration change events.

  • So if you "don't" need to use this feature, is there a section documenting config management strategy per environment?
    – Kevin
    Feb 8, 2017 at 15:06
  • I don't know of one, but that doesn't mean it doesn't exist.
    – Jaypan
    Feb 8, 2017 at 15:13

The answer is $config. Module options are configuration and this is what you override in $config.

$settings is the name space for which settings.php is the primary source, so this is not an override.

The question how to tell whether the overrides are working is indeed pointing to a real problem. You can't see the overrides. The admin UI shows the original values and you can even edit and save them, while the overridden configuration is active in the background.


Your question is not clear, but dev and stage environnemnts have differents settings.php, so you can modify your config in each file as you like, $config contains all globals variables to drupal, and in same time are config variables in data base ...

  • Things that are common between environments should go into settings.php (and this can be committed to version control, assuming nothing in those settings should be kept private). Things that are unique, like database name, user, and pass, should go into a settings.local.php for each enviornment.
    – jenlampton
    May 30 at 19:30

Your Answer

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

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