Score:-3

How can we use \Drupal class inside Settings.php

cn flag

How can we use \Drupal class inside the Settings.php file so that we can load configurations etc? For example:

\Drupal::config('system.site')->get('slogan');
leymannx avatar
ne flag
What do you want to achieve exactly?
Jaypan avatar
de flag
The short answer is that you can't. Settings.php is one of the first files loaded, used to bootstrap the system. The settings are required for bootstrapping. Calling the `\Drupal` class is calling the bootstrapped system, which of course can't be done without loading the settings. So you're in a loop. As leymannx asked, what are you trying to do?
Prashant Chauhan avatar
cn flag
Okay, thanks to both of you for clarifications.
Score:1
cn flag

There is no config available when settings.php is executed. This is in very early stages of the Drupal bootstrap process and neither the database connection nor the service container is initialized.

Prashant Chauhan avatar
cn flag
Okay thanks @4uk4
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.