Welcome Guest, Not a member yet? Register   Sign In
What takes priority, System ENV or .env file?
#1
Question 

Currently the .env file does NOT override the system environment.

I agree and think I can argue for system environment variables having the last say (because it is useful when setting up an environment for e.g. testing to have the env vars scoped). I would argue however that they shouldn't, by default at least, be in the .htaccess that is included in the public folder. The problem with this is that is makes it harder to programatically change the environment when running e.g. continuous integration or tests.

I just wanted to be sure that the sys env has last say is intentional?

Relevant function: https://github.com/bcit-ci/CodeIgniter4/...v.php#L124

Also, while I'm here... is there any place to discuss the development more "live"... like IRC or Slack or?
Reply
#2

Yes, that was done intentionally, though it does only check "local only" variables which limits the scope a little bit.

What variables are you talking about in the .htaccess? The only one that I recall being in there was the CI_ENVIRONMENT, and that's only there because a number of people were having issues where they didn't have access to other locations to set it. I believe that's old though and could probably be removed, as it's now intended to be in the .env file.

Unfortunately, I am not involved in the more real-time chat options as I'm too slammed with the day job to be able to really help that way.
Reply
#3

There is a CI presence on Slack, at https://codeigniterchat.slack.com
It has a CodeIgniter channel, with signups at http://codeignitersignup.ciblox.com/.
This forum has a bigger audience and much more traffic, and might actually be more "live" than Slack.
Reply
#4

Thank you for both your responses.

Yes, I agree that CI_ENVIRONMENT env variable should be removed from .htaccess (and no other env vars should be put there, as per design). The documentation around this can be clearer though... I'll see if I can throw together a changeset for you to pull this evening.

I'll stick to the forum then if that is the most "live" medium Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB