vlucas / phpdotenv

Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
BSD 3-Clause "New" or "Revised" License
13.17k stars 629 forks source link

Dotenv\Dotenv::createImmutable(__DIR__, $env_file) doesn't work in a 2.5.2 version #512

Closed smartbox-jiandonghan closed 2 years ago

smartbox-jiandonghan commented 2 years ago

I am maintaining an old system in which the PHP version is about 5.5, so I can only install the phpdotenv 2.5.2 version.

then I found the code block doesn't work.( it works when I use a higher phpdotenv version with higher php version in other testing environment)

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__, $env_file);
$dotenv->load();   // safeLoad()  also doesn't work
$variable = $_ENV['XXXXXX']

Please give me some instructions or give me a simple example to tell me how the phpdotenv initilization and calling should be when I have to use the phpdotenv 2.5.2 version.

Thank a lot.

GrahamCampbell commented 2 years ago

v4.2.2 is the newest version that works on PHP 5.5. I'd recommend upgrading to that. If you need additional support or are not able to upgrade, ping me at hello at gjcampbell.co.uk, and we can book in some paid consulting time. :)

smartbox-jiandonghan commented 2 years ago

@GrahamCampbell Thank you very much. will contact you soon. best regards.