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

Config merge

Hi, I'm having an issue with merging configs.

I have global config which is shared in my service container. I'm also using multi module structure. In my Module.php file I have

$config = $di->get('config');
print_r($config);

Returns Phalcon\Config Object which is fine.

$moduleConfig = require __DIR__.'/config/config.php';
print_r($moduleConfig);

Returns Phalcon\Config Object which is also fine.

Now I'm trying to merge these two config objects to have a global config.

$globalConfig = $config->merge($moduleConfig);
print_r($globalConfig);

returns null

What am I doing wrong? How to merge these two configs?



6.6k

Just use $config for further processing. The changes should be there. I think merge() has return type void.