3

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;

or

$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

From settings.php, regarding $settings:

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.

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

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.

| improve this answer | |
-1

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 ...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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