Reputation: 568
How does the YiiBase class include the files required in the function "createApplication"??
public static function createApplication($class,$config=null)
{
return new $class($config);
}
I couldn't find the way YiiBase includes "CWebApplication.php" when creating an Yii application
Upvotes: 1
Views: 108
Reputation: 8950
In the YiiBase
class, at the end of the file you can see:
spl_autoload_register(array('YiiBase','autoload'));
This will "bind" the __autoload
magic method to the autoload
method of YiiBase
.
http://php.net/manual/fr/function.autoload.php
In this YiiBase
autoload
method we can see that it uses $_coreClasses variable to try to include the class that is asked.
...
if(isset(self::$classMap[$className]))
include(self::$classMap[$className]);
elseif(isset(self::$_coreClasses[$className]))
include(YII_PATH.self::$_coreClasses[$className]);
...
And this variable contains all the core yii classes:
private static $_coreClasses=array(
'CApplication' => '/base/CApplication.php',
'CApplicationComponent' => '/base/CApplicationComponent.php',
'CBehavior' => '/base/CBehavior.php',
'CComponent' => '/base/CComponent.php',
'CErrorEvent' => '/base/CErrorEvent.php',
'CErrorHandler' => '/base/CErrorHandler.php',
...
);
Upvotes: 2