1

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.

1 Answer 1

3

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

$config['shield.settings']['shield_enable'] = FALSE;
1
  • Instant gratification! That is indeed the correct approach. Thank you! Feb 24, 2021 at 20:30

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.