Welcome Guest, Not a member yet? Register   Sign In
Using numerically indexed arrays in .env file
#1

Is there a way to have a numerically-indexed array in a .env file? My use-case is the configuration app/Config/Logger.php: you can setup the $threshold variable as a number or, since relatively recently, an array. The number indicates to log requests of that level or less, e.g. 

PHP Code:
public $threshold 3// log requests of levels 1, 2 and 3. 
On the other hand, the array lets you indicate precisely what you want, like 

PHP Code:
public $threshold = [1238]; 
Thing is, 8 is the 'debug' level, and for a development environment, it makes sense to have an array like that, whilst
PHP Code:
$threshold 8
includes too much stuff (all warnings and notices, for example).

It would be ideal if I could set this somehow on my .env file, so as not to have to modify the app/Config/Logger.php file, which is committed to git, every time I want to debug stuff. This way, my setup shows debug messages, but others like testing or production don't.

I've tried putting this into my .env, but it does not work,

PHP Code:
logger.threshold.0 1
logger
.threshold.1 2
logger
.threshold.2 3
logger
.threshold.3 
I've seen suggested to use a string like 

PHP Code:
logger.threshold '[1, 2, 3, 8]' 
and then parse it, but this being a class that comes with Codeigniter, I'd rather find a different way to do this if possible.
Reply


Messages In This Thread
Using numerically indexed arrays in .env file - by adrianovaroli - 02-02-2024, 11:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB