I was trying to unravel a little bit how Yii initializes for my own educational purposes. But I got stuck very much at the beginning. So here it goes:
I understand how in index.php two files are being assigned to a variable:
$yii=dirname(__FILE__).'/../framework/yii.php';
$config=dirname(__FILE__).'/../protected/config/main.php';
I understand how the first file gets included by including the variable $yii:
require_once($yii);
I understand that a call is made to a static method in the empty class Yii{} (found in yii.php) which is an extension of the class Yiibase{} (found in Yiibase.php) and that the variable $config is passed to that that method:
Yii::createWebApplication($config)->run();
What I don't understand is:
->run() does and where it comes from?CWebApplication) is created that I don't see included in a file up until that point. How does it know the class CWebApplication{} exists?createWebApplication() # just returns new CWebApplication($config) # which has the run() # method and this class can be easily autoimported by an earlier registration of an autoloder #.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With