-
-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.env processing with symfony using frankenphp worker & runtime #1395
Comments
Does Symfony's
The |
The whole point is that a worker runtime should be a drop in replacement and "just work". With symfony there are also Environment Variable Processors helpers like Ironically, today in my live product (not the reproducer), when in worker mode, now global twig helpers, like the |
This may also be a bug in the Symfony FrankenPHP Runtime instead of in FrankenPHP. For the helpers, could you please report to Symfony? I'll try to take a look next week. The worker mode tries to be as close as possible of the normal mode, but as it is using a totally different paradigm (not fire and forget anymore), both mode can and do slightly differ with edge cases like this one. Using |
Yup, I only posted here because thats where the other conversations about the $_ENV were, but you are right it could be either, or both
As soon as I can get a reproducer for this specific issue, yup I'll report it.
https://symfony.com/doc/current/configuration.html#configuring-environment-variables-in-env-files states "The .env file is read and parsed on every request and its env vars are added to the |
I have a suspicious feeling that this is a weird bug with It only happens on zts builds. I will open a php-src bug this weekend since I have a pretty solid reproducer now. |
The issue seems to be that Symfony's Symfony's It might make sense to generally not flush |
If I remove all env vars from my symfony configs (like HTTP_PROXY in the httpclient) then I can, for the first time ( |
What happened?
This has been talked about this before with no concrete solution or reproducer. The
variables_order = EGPCS
talked about before doesn't seem to fix this.$_ENV
gets overridden #1061 (comment)Finally got a night to play and produce a reproducer to explain the issue for you.
Assuming that the Frankenphp runtime is a drop in replacement, and should "just work" then this needs addressing.
The repo at https://github.com/PhilETaylor/env-reproducer can be
There is one controller action, at / which gives a var_dump of
$_ENV
The reproducer is nothing more thancomposer require runtime/frankenphp-symfony
on top ofsymfony new . --version="7.2.x" --webapp
and then addingHTTP_PROXY
to .env, and adding the runtime to the docker-composeThe problem is that when running with:
the
$_ENV
is missing most of the values from.env
- this means the app breaks because the$_ENV
is not correctly populatedThe values from
.env
are in the$_SERVER
array, but they are not in the$_ENV
array when running the frankenphp runtime.If you then comment out the worker mode in the docker-compose, and then restart your container (which then just runs
image: dunglas/frankenphp
) then compare the dumped$_ENV
from the https://localhost/ you can see the difference, and you can see symfony values such asMESSENGER_TRANSPORT_DSN
and my own test ofHTTP_PROXY
Without Worker Mode Enabled:
With Worker Mode enabled
Visually the changes are:
Other interesting notes
With standard
EGPCS
when you load the reproducer at https://localhost/ the FIRST TIME your$_ENV
contains["DOCTRINE_DEPRECATIONS"]=> string(7) "trigger"
and on the SECOND page refresh its still there. And on the THIRD page refresh IT DISAPPEARS!!!!! STRANGE!!!
If you uncomment the
variables_order=GPCS
in the /php.ini in the reproducer and restart the container, even stranger, you ONLY get theDOCTRINE_DEPRECATIONS
env var when dumping the$_ENV
and no other values!?!?!? and on the THIRD PAGE RELOAD IT DISAPPEARS leaving an empty$_ENV
array dumped.Hope this helps.
Build Type
Docker (Debian Bookworm)
Worker Mode
Yes
Operating System
GNU/Linux
CPU Architecture
Apple Silicon
PHP configuration
Relevant log output
The text was updated successfully, but these errors were encountered: