-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Dotenv] getenv
return false instead of the value in the file .env
#53461
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
Comments
See symfony/src/Symfony/Component/Dotenv/Dotenv.php Lines 56 to 68 in 9afd335
|
closing as explained |
thank you @stof, my question is that the change was in the version 5.0.0, however, we didn't observe this behavior in Symfony 6.3, so I'm wondering if I've missed something or if I still don't fully understand it. thank you |
The behavior change happened with #31957 in 5.0.0. Can you produce a reproducer app for your issue, where we can observe the change of behavior you've described? |
@makraz Did you by chance also update the recipes so that you now have other bootstrapping code in the front controller than you had before? |
Yes, I updated the recipes, and all looks good in this part. I will share a reproducer app for the issue with more context 👌🏻 |
Can you share how your |
Before (Symfony 6.3.2)
Now (Symfony 6.4.2)
|
That's why: recipes are opt-in piece of code that are on your side of responsibility: you don't have to adopt their updates, and adopting them means possibly changing some behavior (as in: reconfiguring some defaults of your app). |
thank you all 🙏🏼 Before:
After:
|
Symfony version(s) affected
6.4.2
Description
after migrating a Symfony project from 6.3.* to 6.4.2 I discovered that the function
getenv
always returnfalse
instead of the value in the file .envalso, I was able to have the same behavior with a new project (Symfony 6.4.2)
How to reproduce
Create a new project Symfony 6.4.2

create a function in a controller that call
dd(getenv('APP_ENV'));
for exampleObserve the results (screenshot)
Possible Solution
No response
Additional Context
tested in below PHP versions:
PHP 8.3.1 (cli) (built: Dec 20 2023 12:44:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies
with Zend OPcache v8.3.1, Copyright (c), by Zend Technologies
/usr/src/app # php --version
Cannot load Xdebug - it was already loaded
PHP 8.2.7 (cli) (built: Jun 15 2023 01:00:47) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies
with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans
The text was updated successfully, but these errors were encountered: