Config\main.php Is Called Every Time A Menu Item Is Selected

Hi

I’m having a problem that my Yii::app->params variables are being reset every time I select an item in the top menu.

So to investigate this, I installed the yii demo application in testdrive

checking in xdebug using Netbeans, it calls index.php which calls the Yii create application every time is select a different item on the menu.

so config\main.php is called each time.

Yii::app->params are reset each time also.

Is this normal?

Is there something in my Apache settings?

I’m running a default Wamp installation.

Just a hint to tell me where to look would be enough for me.

Thanks,

Neil

I guess that you are new to web development. And as I understand selection of the new item in the menu loads a new page, right?

It is normal that your application starts from scratch - this is because of stateless nature of web application - each request to the server spawns new application instance.

If you came from the desktop apps area (as I did) then this can be confusing at the beginning: every action performed by your user usually results in a request to the server, every server request starts and initializes application each time.

To keep some state you can use database (for permanent data) or session (for temporary data).

Thanks Seb for this. This is very helpful.

I will use session now to keep data because Yii::app()->params variables are being cleared everytime Yiiroot\index.php is called.

Neil