Skip to content

Commit

Permalink
Allow APP_ENV override from $_ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Dec 19, 2023
1 parent ddfcc93 commit 3fd60b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
======================

Expand Down
5 changes: 5 additions & 0 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 3fd60b3

Please sign in to comment.