3

If I have multiple services.yml in the sites/default/ directory, how can I determine which one Drupal is actually loading?

Is there a drush command to check this? Or is there some other way to verify which services file is being used by a site?

2
  • 2
    I'm wondering how you can have multiple files with the same name? If you have files with different names you need to add them to $settings['container_yamls'] in settings.php. You can compile the service container with as many yaml files as you want. For example modules can provide yaml files, too, which are loaded without settings. – 4k4 Jun 18 at 15:33
  • @4k4 I was confused by this "Best practices" recommendation from the Site Audit module: Site-specific services.yml in use. Use of a site-specific services.yml is unnecessary for most sites, and can cause issues as it overrides core.services.yml. See https://www.drupal.org/project/drupal/issues/2547447. – Patrick Kenny Jun 18 at 16:12
2

The info is stored in global settings, but it isn't necessarily one file. To get the currently active list:

$container_yamls = \Drupal\Core\Site\Settings::get('container_yamls');

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.