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 configuration for each registered module to use in plugin

I am developing a plugin which is being executed in the beforeRender event of the view. This plugin can be configured by: a. the default config.php file which comes with the plugin and b. in the general config of the application.

but it should also be possible to set module specific configuration for the plugin.

I know it's possible to get all registered modules, but how do I get the configuration for that module?

As far as I know it's only possible to:

  • let the developer of the module include a method to return the specific configuration and call that method by creating an instance of that module (because you don get the moduleÅ› instance but only the classname).

(This seems to work by the way, but isn't there a better way).

Subquestion: are all configs being merged by the application instance and is the complete config available somehow?



58.4k
edited Oct '14

Hi Hi I don't understand your idea, but may be this is . For example multi module in Phalcon. We define config.php in module is Frontend and define config.php in folder common, so in Module frontend you can merge config or not that

$module_config = include __DIR__ . '/config/config.php';
//megre config file
$di->get('config')->merge($module_config);
$config = $di->get('config');