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.
- http://railsapps.github.io/rails-environment-variables.html
- https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
- ... more ...
User interface changes
None.
API changes
Facilitates an environment variable: DRUPAL_ENV