I've noticed since Craft 3.4.18 there is a App::env() function from craft\helpers\App::env(). This was created from the discussion here it seems: https://github.com/craftcms/cms/pull/5893

It seems getenv() can be problematic on multithreaded environments, which is why this change was made.

Should getenv() calls be replaced by App::env() in PHP code now, if using Craft 3.4.18 or above given the App::env() function will check $_ENV first then use getenv() as a fallback?



It’s not a requirement, but relying on App::env() is the current best practice and we’ve updated the Composer starter project to use it: https://github.com/craftcms/craft/blob/master/config/db.php

  • Thanks Matt, I did notice this, I saw it being used in db.php and app.php, thank you for clarifying. – James White Jan 14 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.