diff --git a/README.md b/README.md index fb6cc988..0b9d6c2b 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,17 @@ See one of the following guides: [Production installation](docs/deployment.md) +Setting the desired Symfony application environment +=================================================== +There are 2 ways you can influence the desired Symfony application environment. + +1. Set the `app_env` parameter in `config/openconext/parameters.yaml` to `dev`, `test` or `prod` +2. Override the `app_env` param by providing an environment variable named `APP_ENV` + +- The default value for the application environment will be `prod` +- Do not try to use a .env file to override the `app_env` param. That file will not be evaluated by Symfony as we decided not use the DotEnv component. + + Tests and metrics ====================== diff --git a/config/bootstrap.php b/config/bootstrap.php index e0c74aeb..9c7d3a6c 100644 --- a/config/bootstrap.php +++ b/config/bootstrap.php @@ -21,4 +21,9 @@ $_SERVER['APP_DEBUG'] = $parameters['app_debug']; $_SERVER['APP_SECRET'] = $parameters['app_secret']; +// Allow the application environment (dev/test/prod) to change via the APP_ENV environment variable. +if (array_key_exists('APP_ENV', $_ENV)) { + $_SERVER['APP_ENV'] = $_ENV['APP_ENV']; +} + filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';