phabion
(Trinhduyhung1985)
1
Hello everyone!
I’m learning yii framework and have a quite simple question.
We know that Yii::app() returns a CApplication object. When I consult to Yii api documentation for static method app() I see something like:
public static function app()
{
return self::$_app;
}
But the thing is I couldn’t find $_app inside yiiBase class. I’m wondering where does this guy $_app come from?
Thank in advanced!
redguy
(Maciej Lizewski)
2
attribute definition is in 75 line of https://github.com/yiisoft/yii/blob/1.1.12/framework/YiiBase.php
setting the value of this attribute is done like this:
front controller (index.php) has this line of code:
Yii::createWebApplication( $config )->run();
this creates CApplication instance and calls run() method. During initialisation of CApplication there is a call to
Yii::setApplication($this);
in CApplication::__construct()
and that is all.