I want to access the variables present in the settings.php in my custom module. For example, if the settings.php file contains the $config['test']['uid'] = 'ABC'; line, I want to access the content of $config['test']['uid'] in a controller.

How can I achieve this?

  • Welcome to Drupal Answers! Just added a snippet for Drupal 8 to the linked question.
    – leymannx
    Apr 3, 2019 at 10:09

1 Answer 1


You can only override configuration values in settings.php, you cannot introduce new configuration. So the values you have tried to set there cannot be accessed, unless you happen to have configuration named test.uid. But I suspect that probably does not exist.

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