Laravel's documentation for upgrading from 5.2 to 5.3 indicates the following:
Caching and Env
If you use the command config:cacheduring deployment, you should make sure that you envonly call the function from your configuration files, and not anywhere else in your application.
If you are calling envfrom your application, it is highly recommended that you add the correct configuration values to your configuration files and call envfrom this place instead , which allows you to convert your envcalls to configuration calls.
The question the documentation doesn't answer is: why?
Should the assistant env()when it is used in the application still work correctly? Can't I still use the env()configuration after caching, instead of having to find it in my entire project and replace it with an assistant config(), as (indirectly) suggested by the docs?
For example, if I have this in my app.php :
'env' => env('APP_ENV', 'production')
and it will be cached using config:cache, but I'm still using an assistant env()somewhere in the code, then is there any reason whatsoever that env('APP_ENV')will give me something else than config('app.env')?
What about a call App::environment()- is it also not recommended to config:cacheuse it after it is used for production?