Welcome Guest, Not a member yet? Register   Sign In
env file and boolean values ​​such as true or false
#6

I think the solution is to let the Dotenv value to empty.

Let's say I have a boolean Dotenv variable such as email.DSN. To set it to false, I use:
Code:
# Use the following to set the value to false
email.DSN =

If I set any other value, it will be considered as true, event if I set it to false.
For example the following values will result in true in the code.
Code:
# All the following values will be considered true
email.DSN = false
email.DSN = 0
email.DSN = whatever
email.DSN = true
email.DSN = 1

Note: I don't think using env() function is a good solution if the Dotenv variable corresponds to a config value.
In my example, there is a 'DSN' variable in the app/Config/Email.php file:
PHP Code:
public bool $DSN false
As the env() function does not read the config file, if I remove the value of email.DSN from the Dotenv file, then env('email.DSN') will return null and not the value that is in the config file.
Reply


Messages In This Thread
RE: env file and boolean values ​​such as true or false - by parisiam - 03-21-2023, 12:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB