craftcms/craft

CRAFT_ENVIRONMENT vs. ENVIRONMENT

swey opened this issue · 2 comments

swey commented

The .env uses ENVIRONMENT, while the CMS uses CRAFT_ENVIRONMENT. If the example env file is used, the environment variable will have no effect. Not sure, which one is the right.

https://github.com/craftcms/craft/blob/master/.env.example#L2
https://github.com/craftcms/cms/blob/develop/bootstrap/bootstrap.php#L104

They both are right :)

All of Craft’s PHP constants begin with CRAFT_ because their names aren’t configurable and something more generic (e.g. ENVIRONMENT) might conflict with other systems. So we err on the safe side for those.

The environment variables are configurable though. This starter project just defines the default names, but you could change them if you wanted; it’s just a matter of updating your .env file and the getenv() calls in the various config files where they are accessed. Or in ENVIRONMENT’s case, in web/index.php and the craft executable.

swey commented

Ok, got it. Thank you!

Our problem was that we updated the env variables without updating the web/index.php