Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297864

Allow configuring the environment via an environment variable

$
0
0

Problem/Motivation

Something which is pretty common in other frameworks and standalone applications is getting the current environment from an environment variable. Rather than a hardcoded 'prod' we should be able to easily configure this value from the environment.

Proposed resolution

A call to getenv() will give us a value, I would suggest 'DRUPAL_ENV' maybe? So you could set this in the following ways:

- In your actual environment: export DRUPAL_ENV=staging
- Apache: SetEnv DRUPAL_ENV staging
- Nginx: fastcgi_param DRUPAL_ENV staging
- Using putenv() (settings.php etc..)
- Using Symfony's dotenv component or phpdotenv library

Everything else is in place to dump an environment specific container. The 'kernel.environment' variable will also be available to use (already there too).

So E.g. you could set this in a test like: putenv('DRUPAL_ENV=test') too.

Remaining tasks

Document the new DRUPAL_ENV environment variable.

User interface changes

None.

API changes

Facilitates an environment variable: DRUPAL_ENV


Viewing all articles
Browse latest Browse all 297864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>