I have a drupal 8 custom module with some parameters declared inside services.yml file.

  custom_module.api_host: 'https:test-url.com'
  custom_module.api_username: 'multi'
  custom_module.api_password: 'testpassword'
  custom_module.api_client_uuid: '2f21a060-dd35-1122-88fg-98577b1abc31'

How can I pass those variables to settings.php file and use it from services.yml?

I tried solution from here, but it doesn't work inside services.yml file.

  • I'm not sure how this is connected with the linked post and settings.php. If you want to override container parameters set by a module use /sites/default/services.yml
    – 4k4
    Oct 1 at 9:46
  • do you have some examples how to use variables from site services.yml into module service.yml? Oct 1 at 12:28
  • It's the other way, site service.yml is called later and overrides any parameter set by modules.
    – 4k4
    Oct 1 at 12:37
  • do you mean I can remove parameters from custom module and declare them only in services.yml of the website? Oct 1 at 12:40
  • In theory yes, but I don't think this is recommended because the site services.yml file is optional and then a service which depends on the parameter will throw an error when the container is compiled on a cache clear
    – 4k4
    Oct 1 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.