Provide better support for environment variables

Created on 19 May 2017, about 7 years ago
Updated 18 June 2024, 14 days ago

Problem/Motivation

Environment variables to pass in global settings/configurations are a thing:

  • Most hosters have some sort of support for them and expose the DB settings as such, for example https://github.com/pantheon-systems/drops-8/blob/master/sites/default/settings.pantheon.php#L39
  • It really explitely defined to be environment specific.
  • Many systems have .env files to share those.

Usecases

Pro/Cons

Questions

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🌱 Plan
Status

Active

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 17 minutes ago

Created by

πŸ‡©πŸ‡ͺGermany dawehner

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    It would be lovely to use a .env to set environment variables for testing. This would make it much simpler to swap between Drupal 10 and 11 for testing purposes.

    I propose we add the Symfony dotenv library as a dependency and use it to load files from the root directory of the project. We could add

    // loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV
    $dotenv->loadEnv(__DIR__.'/.env');
    

    to core/tests/bootstrap.php so environment variables are available when testing and we could add it to \Drupal\Core\DrupalKernel::bootEnvironment() to ensure it is loaded when we boot.

    This would allow consist environment management for Drupal core dev and projects built on Drupal.

Production build 0.69.0 2024