Question

I'm trying to learn the Drupal 8 configuration override system based on the documentation here:

https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-override-system

As a simple test, I have disabled the Shield module and exported config. Here's a diff:

diff --git a/config/sync/shield.settings.yml b/config/sync/shield.settings.yml
index 3f7482f18..d9f019ca4 100644
--- a/config/sync/shield.settings.yml
+++ b/config/sync/shield.settings.yml
@@ -1,4 +1,4 @@
-shield_enable: true
+shield_enable: false
 credential_provider: shield
 credentials:
   shield:

Now, in my settings.local.php I have attempted to override this config key:

/**
 * Disable Shield (HTTP Basic Authentication).
 */
$config['shield']['shield_enable'] = FALSE;

This approach does not seem to work.

Do I need to do anything else to override the configuration?

NOTE: This is a contrived example. I could use configuration splits to disable HTTP basic auth in the production environment, even if it's enabled in the active database configuration. In fact, I am hoping this approach will allow me to use environment variables to provide environment-specific values for authentication tokens, API keys and other secrets that may change in sandbox and production environments, but details are irrelevant to the question.

Était-ce utile?

La solution

The key for $config is the config name, not the module. This should work:

$config['shield.settings']['shield_enable'] = FALSE;
Licencié sous: CC-BY-SA avec attribution
Non affilié à drupal.stackexchange
scroll top