Welcome Guest, Not a member yet? Register   Sign In
array in .env file
#1

In App.php there is an array variable:
    public $toolbarCollectors = [
        'CodeIgniter\Debug\Toolbar\Collectors\Timers',
        'CodeIgniter\Debug\Toolbar\Collectors\Database',
        'CodeIgniter\Debug\Toolbar\Collectors\Logs',
        'CodeIgniter\Debug\Toolbar\Collectors\Views',
//        'CodeIgniter\Debug\Toolbar\Collectors\Cache',
        'CodeIgniter\Debug\Toolbar\Collectors\Files',
        'CodeIgniter\Debug\Toolbar\Collectors\Routes',
        'CodeIgniter\Debug\Toolbar\Collectors\Events',
    ];

Is it possible to define an array variable in .env file?
For example:
app.css_files = [
     'bootstrap.css',
     'fontawesome.css',
     'stylesheet.css'
]
or
app.css_files = ['bootstrap.css', 'fontawesome.css', 'stylesheet.css']
Reply
#2

This array doesn't sounds as environment thing, probably it's place is not in the .env

.env should be used to put only specific configuration settings which are critical for running the environment not everything..
In some cases you can even not use the .env and to set such settings directly at config files if it is will be same for all env's.


How ever at the moment I see maybe only option to set json array string as setting (in single line) at .env and to parse it where you use it.

app.css_files = '["bootstrap.css","fontawesome.css","stylesheet.css"]'
Best VPS Hosting : Digital Ocean
Reply
#3

app.css_files = '["bootstrap.css","fontawesome.css","stylesheet.css"]' is returning a string. In .env file there is an example but I think it doesn't work either. If so, CodeIgniter4 .env file style may be changed from apache to json or something else.
# app.CSRFExcludeURIs = []
Reply
#4

Er, don't we already have what you are asking for?
https://bcit-ci.github.io/CodeIgniter4/g...-as-arrays
Reply
#5

(This post was last modified: 10-15-2018, 03:33 AM by sv3tli0.)

(10-14-2018, 09:14 PM)obozdag Wrote: app.css_files = '["bootstrap.css","fontawesome.css","stylesheet.css"]' is returning a string. In .env file there is an example but I think it doesn't work either. If so, CodeIgniter4 .env file style may be changed from apache to json or something else.
# app.CSRFExcludeURIs = []

Yes, you need just to json_decode($IT, true) to get normal array. I think this is more then enough for such type of LIST.


(10-14-2018, 10:39 PM)ciadmin Wrote: Er, don't we already have what you are asking for?
https://bcit-ci.github.io/CodeIgniter4/g...-as-arrays

Yes but those are assoc arrays. He is asking for just a list of entries without keys..

Code:
SimpleConfig.address.city = "Berlin"
SimpleConfig.address.country = "Germany"
vs
Code:
SimpleConfig.address.0 = "Berlin"
SimpleConfig.address.1 = "Munich"
Best VPS Hosting : Digital Ocean
Reply




Theme © iAndrew 2016 - Forum software by © MyBB