env not parsing boolean
Just today the application I'm working on started to display debug information. Uppon inspection the issue is that APP_DEBUG=false when read by env('APP_DEBUG',false) is returning string insted of boolean type.
Anyone ever experienced this?
It is supposed to be a string in the .env file. That value is parsed by Laravel framework into a boolean in the function env() located in /vendor/laravel/framework/src/Illuminate/Support/helpers.php. Try clearing the config cache.
The ONLY place you should be reading the .env file with env() is from within a config file in /config.
If you need to access it outside of there, use the config helper, which will show the correct php value.
get the debug value from /config/app.php
dd(config('app.debug')); // true/false (boolean)
It got stranger... so in develpment I don't have the issue. So live editing on production :(
for some reason the env function in helpers.php is not being called. Some thing else is beeing called. have all ready done co:cl, vi:cl, ca:cl and also composer update.
will get back if I find anything else.
That is strange. First, if you ever change a .env value or in the actual config files, you need to run the artisan command to clear the config cache as Laravel caches all configs for efficiency. Now, if you did change the value in the actual config file, you need to make sure it is a string(except for Booleans)...the .env assumes it is a string and is parsed as such with a switch statement that changes true/false to a boolean in the previous file I directed you to.
By any chance are you using Laravel Debugbar? That may be your issue.
You probably need to run artisan config:clear. If the config is cached (recommended on production), laravel doesn't even use env() any longer. It uses the cached config values to speed things up (reading from env() is slow). This is why I (actually the manual) said to not use env() outside of actual config files in the /config dir.
See the big orange warning here: https://laravel.com/docs/5.6/configuration#configuration-caching
CAKEPHP confilct.
The issue was that a component that I use (resumable.js) included cakephp. cake also has a function env(), that does not do casting. For some reason, this function was being called insted of env() in helper.php. This probably has other side affects so for now I just renamed the env() in cake to cakeenv, and problems seem to be "resolved".
I will try to to implement better configuration options form now on specially with regards to using env() function.
Please or to participate in this conversation.