Get one element of the array with get(): $this->config->get('database.adapter', 'MySql')

as I can bring an element of an array config->get('array.element')?

I try:

$this->config->get('database.adapter');

there should be some way to get an item from a list.

edited Sep '16

$this->config->get('database')->apadter; ?



67.7k
$this->config->get('database')->apadter;

?



67.7k

the good from the get function is that you can set a default value.

if to a default value, you would do:

$adapter = $this->config->database->adapter ? $this->config->database->adapter : 'MySql' ;

?

@Izo hahahaha -> finger error. That happens when you do not use CTRL-C



67.7k
edited Sep '16

i dont think its good practise to have if config .....

you need to put some getters in the config, or set/update those properties after init

You're telling me I have to extend Phalcon\config



67.7k

its up to you how you gonna do it, but in my mind config should be something solid that you can always relay on, because you hard coded it yourself. Nothing should go wrong. At least in my mind. I could be wrong

'Phalcon/config' is mutable. but not have set()