Access of env-vars in Constants.php |
Hi,
i wanted to do something like that in the Config/Constants.php: PHP Code: define('IS_LIVE', getenv('CI_ENVIRONMENT') == 'production'); but i have no access to the env-variables. How could i do that? I want to keep this variables because in my old CI 3 installation i use this constants a lot and migration would be easier. A second question: Where is the ENVIRONMENT constant defined? I found this term in the documentation. Is this the CI_ENVIRONMENT in the env file?
If you set CI_ENVIRONMENT by .env file, it is not loaded yet when Config/Constants.php is loaded.
The ENVIRONMENT is defined in CodeIgniter::detectEnvironment(). It is not CI_ENVIRONMENT, but when ENVIRONMENT is not defined, CI_ENVIRONMENT value will be set.
Thank you.
Is there an alternative what i can do instead in order to keep these constants? Do i have to create something different and change the constants? (helper, files in Config/Boot Directory). It was nice if you can give me an idea, thanks.
Move the define() to app/Config/Boot/*.php
|
Welcome Guest, Not a member yet? Register Sign In |