Skip to content

[Dotenv] getenv return false instead of the value in the file .env #53461

@makraz

Description

@makraz

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 return false instead of the value in the file .env
also, 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 example
Observe the results (screenshot)
image

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions