CodeIgniter Forums
How / When / How 'env' is parsed? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: How / When / How 'env' is parsed? (/showthread.php?tid=75517)



How / When / How 'env' is parsed? - glihm - 02-14-2020

Dear community,

I was a CodeIgniter 3 user, and now diving into CodeIgniter 4.

I am trying to use 'env' functionality, but even if I un-comment the
line for CI_ENVIRONMENT, the variable ENVIRONMENT value still 'production' in my code.

I have tried
PHP Code:
getenv('CI_ENVIRONMENT'
but it is not defined.

To follow, I have added a variable as the documentation said, MYTEST = "value1" in the 'env' file,
and in a controller, using
PHP Code:
getenv('MYTEST'
returns undefined.

I am probably doing something wrong, thank you for your lights!

glihm


RE: How / When / How 'env' is parsed? - jreklund - 02-14-2020

Hi, have you renamed your env into .env?


RE: How / When / How 'env' is parsed? - glihm - 02-15-2020

(02-14-2020, 11:46 PM)jreklund Wrote: Hi, have you renamed your env into .env?

... I do apologize for that. Thank you very much jreklund. Smile


RE: How / When / How 'env' is parsed? - jreklund - 02-15-2020

No need to apologize, glad it worked out for you! :-)