I just experienced some inconsistencies between web applications and console applications. It turns out, that console applications don’t define aliases for modules. So when trying to use some component from an module in a console application, the following code will cause an exception:
public function behaviors()
{
return array(
'someBehavior' => array(
'class' => 'moduleId.behaviors.SomeBehavior',
),
);
}
The same works well in web applications: “moduleId” is recognized as alias, the module will be loaded and initialized, everything’s okay.
Since the alias isn’t recognized in a console app, you have to use another alias like this:
public function behaviors()
{
return array(
'someBehavior' => array(
'class' => 'application.modules.moduleId.behaviors.SomeBehavior',
),
);
}
But this only leads to more problems: The module won’t get loaded nor initialized. Since my module does some important stuff during initialization (setting imports, configuring the components it ships, …) bypassing the initialization is a serious problem.
So now I wonder, why console applications don’t support modules in the same way web applications do?