TransWikia.com

Use of App::env() compared to getenv() since Craft 3.4.18

Craft CMS Asked by James White on June 11, 2021

I’ve noticed since Craft 3.4.18 there is a App::env() function from crafthelpersApp::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?

One 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

Correct answer by Matt Stein on June 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP