You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using only environment variables to configure Symfony, you end up with debug mode enabled even when APP_ENV=prod. This only happens when symfony/dotenv is not installed.
Installing dotenv will disable debug in prod mode by default. Even if you do not use .env files, installing this package will change this behavior. See \Symfony\Component\Runtime\SymfonyRuntime.
One might not have dotenv installed in a production environment as it should not be needed or when using an older setup. Past versions of the Symfony Skeleton did have symfony/dotenv as require-dev and not require dependency.
How to reproduce
$ composer create-project symfony/skeleton sf
$ cd sf
$ bin/console
will print (env: dev, debug: true)
$ APP_ENV=prod bin/console
will print (env: prod, debug: false)
$ composer remove symfony/dotenv
$ APP_ENV=prod bin/console
will print (env: prod, debug: true)
$ APP_ENV=prod APP_DEBUG=false bin/console
will print (env: prod, debug: false)
Possible Solution
I would suggest to always disable debug mode within the prod environment unless explicitly enabled. It is hard to notice and unexpected otherwise.
E.g. change the fallback to false in \Symfony\Component\Runtime\GenericRuntime which currently is true:
…d (nicolas-grekas)
This PR was merged into the 5.3 branch.
Discussion
----------
[Runtime] fix defining APP_DEBUG when Dotenv is not enabled
| Q | A
| ------------- | ---
| Branch? | 5.3
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#43793
| License | MIT
| Doc PR | -
Commits
-------
189987a [Runtime] fix defining APP_DEBUG when Dotenv is not enabled
Symfony version(s) affected
5.3.9
Description
When using only environment variables to configure Symfony, you end up with debug mode enabled even when
APP_ENV=prod
. This only happens whensymfony/dotenv
is not installed.Installing dotenv will disable debug in prod mode by default. Even if you do not use .env files, installing this package will change this behavior. See
\Symfony\Component\Runtime\SymfonyRuntime
.One might not have dotenv installed in a production environment as it should not be needed or when using an older setup. Past versions of the Symfony Skeleton did have
symfony/dotenv
asrequire-dev
and notrequire
dependency.How to reproduce
$ composer create-project symfony/skeleton sf
$ cd sf
$ bin/console
$ APP_ENV=prod bin/console
$ composer remove symfony/dotenv
$ APP_ENV=prod bin/console
$ APP_ENV=prod APP_DEBUG=false bin/console
Possible Solution
I would suggest to always disable debug mode within the prod environment unless explicitly enabled. It is hard to notice and unexpected otherwise.
E.g. change the fallback to
false
in \Symfony\Component\Runtime\GenericRuntime which currently istrue
:Additional Context
No response
The text was updated successfully, but these errors were encountered: