Answers.Body: <p>Yes.</p>
  <p>It’s not a requirement, but relying on <code>App::env()</code> is the current best practice and we’ve updated the Composer starter project to use it: <a href="https://github.com/craftcms/craft/blob/master/config/db.php" rel="nofollow noreferrer">https://github.com/craftcms/craft/blob/master/config/db.php</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-14T07:53:57.973Z
Answers.Text: Thanks Matt, I did notice this, I saw it being used in db.php and app.php, thank you for clarifying.
Answers.UserDisplayName: James White
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-13T22:45:48.613Z
Answers.LastActivityDate: 2021-01-13T22:45:48.613Z
Answers.UserDisplayName: Matt Stein
Body: <p>I've noticed since Craft 3.4.18 there is a <code>App::env()</code> function from <code>craft\helpers\App::env()</code>. This was created from the discussion here it seems: <a href="https://github.com/craftcms/cms/pull/5893" rel="nofollow noreferrer">https://github.com/craftcms/cms/pull/5893</a></p>
  <p>It seems <code>getenv()</code> can be problematic on multithreaded environments, which is why this change was made.</p>
  <p>Should getenv() calls be replaced by <code>App::env()</code> in PHP code now, if using Craft 3.4.18 or above given the <code>App::env()</code> function will check <code>$_ENV</code> first then use <code>getenv()</code> as a fallback?</p>
  
Tags: <php><config>
Title: Use of App::env() compared to getenv() since Craft 3.4.18
ThreadText: # Use of App::env() compared to getenv() since Craft 3.4.18
  
  (Asked by: username_0 on 2021-01-13)
  
  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?
  
  **Tags:** php, config
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-13. Score: 1 | Accepted answer
  
  Yes.
  
  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>
  
  > **Comments:**
  > **username_0**: Thanks username_1, I did notice this, I saw it being used in db.php and app.php, thank you for clarifying.  
  
  ---
  
  