We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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; ?



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

?



85.5k

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



85.5k
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



85.5k

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()