3

I add the following to the end of my settings.php

$config['system.site']['name'] = 'Drupal 8 DEVELOPMENT';

When I run drush cget system.site name it still displays the old site name.

Any idea why it wouldn't be overriding?

7

You can use the --include-overridden option to show overridden config, for example:

drush cget --include-overridden system.site name
4

This is intentionally. settings.php doesn't change the configuration in database. It overrides the configuration only for the actual request.

If you remove the line from settings.php, you restore the configuration to the original value.

You can even edit the original configuration in UI, while it is overridden in settings.php.

You can check this:

drush ev "var_dump(\Drupal::config('system.site')->get('name'))"

has the result: Drupal 8 DEVELOPMENT

But if you use these commands:

drush cget system.site name
// is the same as
drush ev "var_dump(\Drupal::configFactory()->getEditable('system.site')->get('name'))"

the result will be the site name configured in Basic site settings.

4

Because I haven't found it spelled out clearly anywhere in the docs, I'm gonna write it here for posterity.

In settings.php:

  • Use $config to override a value which you would access from \Drupal::config()
  • Use $settings to override a value which you would access from \Drupal::settings()
  • Values accessed from \Drupal::state() cannot be overridden from settings.php

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.