About yii modules

Hi All,

I would like to ask, if i have define modules in config/main, the system will pre load the the models in my modules too or will only load models when modules was call? If i have many modules will it cause slow loading?

Thanks

As almost everything in Yii, it will only load when required

your app performance will stay the same

It will load when the url routes to it or when you use




Yii::app()->getModule('myModule');






If i was going to set in config/main.php ( method 1 )

'modules'=>array(

		// uncomment the following to enable the Gii tool

		

	'gii'=>array(

		'class'=>'system.gii.GiiModule',

		'password'=>'skcstore123',

	 	// If removed, Gii defaults to localhost only. Edit carefully to taste.

		'ipFilters'=>array('127.0.0.1','::1'),

	),

	'member',

	'myAccount',

	'myOrder',		

	),


or method 2 ( in yii index.php )




$yii = Yii::createWebApplication($config);

$yii->setModules(array('member'));

$yii->setModules(array('myAccount'));

$yii->setModules(array('myOrder'));

$yii->run();



May i know is that both performance is the same or which one will be more suitable?

the performance will stay the same, but method 1 is the best way for most cases

use the method 2 when you, for example, load the modules from the database or something like that

Thanks Gustavo, now i already understand. I will choose method 2 because i will need to pull modules from database. Thanks :)

Glad I could help

By the way, I would do it like this




//config file

return array(

//...

'onBeginRequest'=>array('Bootstrap','begin'),

//...

);

//components/Bootstrap.php

class Bootstrap{

 static function begin( $event ){

  //this will execute when the application is read to run, before anything else

  //load from database and set the modules here

 }

}



But my situation is i need to call database value to define what module should load, so i think i can use this method.