Yii Framework Forum: Config\main.php Is Called Every Time A Menu Item Is Selected - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Config\main.php Is Called Every Time A Menu Item Is Selected I'm having a problem that my Yii::app->params variables are be Rate Topic: -----

#1 User is offline   Neil Kenealy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 31-October 11

Posted 29 November 2012 - 01:48 AM

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
0

#2 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 29 November 2012 - 03:25 AM

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).
0

#3 User is offline   Neil Kenealy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 31-October 11

Posted 29 November 2012 - 03:47 AM

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users