Reputation: 1610
I would like to setup a staging
environment with the same configuration as the prod
environment.
According to the docs, I proceed as follow:
I create a staging
symlink that points on prod
APP_ENV=staging
php bin/console cache:clear
When the APP_ENV=prod
, my custom error page is render properly, but when APP_ENV=staging
, the debug message NotFoundHttpException
is rendered?
The profiler is not displayed.
What am I missing?
Upvotes: 1
Views: 530
Reputation: 47308
Crate an .env.staging
file and use it to set APP_DEBUG
to 0
. Debug mode and environment are set independently.
By default, unless you set it explicitly debug mode (APP_DEBUG
) is set from the environment automagically.
This happens in the following steps:
In your front-controller (index.php
, usually) you would find this line:
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
And on DotEnv::bootEnv()
you'll find this:
$debug = $_SERVER[$k] ?? !\in_array($_SERVER[$this->envKey], $this->prodEnvs, true);
This will compare your APP_ENV
with an array of "environments" that DotEnv
, considers "production-like". By default, this array includes only prod
.
You could modify the instance of the DotEnv
by calling setProdEnvs()
:
(new Dotenv())
->setProdEnvs(['prod', 'staging'])
->bootEnv(dirname(__DIR__).'/.env');
... but generally simply disabling debug mode on your .env
file would be enough.
Upvotes: 2