life cycle of application and application component


As per definitive guide, when user access the application an instance of application singleton is created and request is resolved to controller and action, i have some confusion in understanding following :

A new application instance is created each time user clicks on a link in our application?

The application components configured in main.php are instantiated when required, eg user component or say db component, when we access say Yii->app()->user, we are access user component object, right? and similarly in case of Yii->app->db we access the object of CDbconnection class, now weather these objects are once created and stored in session or each time we access new object is created when we access a link (which i think not possible because we save persistence data in user component?)

Or is there some other tweek, so that we are passing objects from one request to another, because as per my knowledge when a new page is loaded all objects variable becomes non existence except that stored in session, or Global variables.

kindly help


use this extension to see what components loaded every time

: yiiDebugToobar


Hi, let me try to sort things out

yes, but this is not special about yii. this is typical for the vaste majority of applications running over http(s) and is due to the nature of statelessness of http(s) protocol.

majority of objects created through runtime are not stored in session.

no persistance, unless you create it

no, no tweak that i am aware of

absolutely right. due the fact that http(s) is stateless


absolutely right. due the fact that http(s) is stateless

Thank you very much guaruja for such a elaborate reply, while learning Yii I am also enjoying learning of OOP techniques.