Programmatically Loading Of Modules Upon Login

Hi, I’m trying something out in Yii. (i’m new to yii by the way) Is it possible to dynamically load a module after a user logs in to the system? As what I have understood, modules are initialize upon calling the webApp right? or i have misunderstood the concept. please shed some light. thanks

Modules are only initialized if you use them.

  • when you call a url to a controller inside the module: mymodule/controller/action

  • when you call


  • when you use the module id as first part in Yii::getPathOfAlias like

     $pathToModuleViews = Yii::getPathOfAlias('mymodule.views');

     //but this will not initialize the module

     $pathToModuleViews = Yii::getPathOfAlias('application.modules.mymodule.views');


Besides: the same for (application) components.

They only will by initialized on the first usage.