Hello everyone,
I have three modules and one task, one of them contains purely model classes which are used from the other components.
Due to requirements of the company, I must put the db configuration within the modules. (and they have to be modules)
Now, it is working when I set the db configuration in one of the two public modules and everything works fine if I access any of them. But when I place it within the common module, it does not work. The two public modules are including the common one by using the add_module method.
Placing it within the public modules would not usually be a problem, except that I have a task that uses the common module as well, in which case the db connection will not be available.
Is there a way to force the public modules and / or task to load a db connection when adding the common module? I have tried many permutations of the \Config::load('common::db'), etc, etc without luck.
add_module() only adds the module path to the autoloader, it doesn't call or execute something. Unlike packages, modules don't have a bootstrap that is called upon load.
The only option is to always_load the module, and then call a class method statically from somethere in the startup flow, or perhaps from your db config file, so it gets called when the db config is read (is probably the most transparent for the application).
There is no way to deal with this without making provisions for it in your app.