Array in .env file - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Array in .env file (/showthread.php?tid=75164) |
Array in .env file - rich8374 - 01-03-2020 I was hoping from the docs here: Treating Environment Variables as Arrays that I could access something in the .env file that used dot syntax as an array but it doesn't seem to work.[url=https://codeigniter4.github.io/userguide/general/configuration.html#treating-environment-variables-as-arrays][/url] Here is an example, after copying the env file to .env and uncommenting the database.default section: PHP Code: $database = getenv('database'); $database just contains boolean false. Is it possible to access everything prefixed with e.g. 'database' as an array? Thanks. RE: Array in .env file - InsiteFX - 01-03-2020 It will not work because it does not have a namespace or class. RE: Array in .env file - rich8374 - 01-03-2020 thanks but actually I think my fault was using the getenv command. The following works: PHP Code: $database = config('Database'); and shows that database.default is an array |