A procedure entrance
<?php
//change the following paths if necessary
$yii =dirname (__file__). ' /http://www.cnblogs.com/framework/yii.php ';
$config =dirname (__file__). ' /protected/config/main.php ';
Remove the following line when in production mode
//defined (' Yii_debug ') or define (' Yii_debug ', true);
Require_once ($yii);
Yii::createwebapplication ($config)->run ();
The require_once ($YII) statement contains the yii.php file, which is a yii bootstrap file that contains the base class for Yiibase, and Yii fully inherits the Yiibase
<?php
/**
* Yii bootstrap file.
* *
@author Qiang xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @version $Id: yii.php 2799 2011-01-01 19:31:13z Qiang.xue $
* @package System
* @since 1.0
/require (dirname). ' /yiibase.php ');
/**
* Yii is a helper class serving common framework functionalities.
*
* * It encapsulates {@link Yiibase} which provides the actual implementation.
* By writing your own Yii class, you can customize some functionalities of yiibase.
*
* @author Qiang xue <qiang.xue@gmail.com>
* @version $Id: yii.php 2799 2011-01-01 19:31:13z qiang.xue $< c21/>* @package System
* @since 1.0
/
class Yii extends Yiibase
{
}
Some of the yiibase classes are defined as:
public static function Createwebapplication ($config =null)//Create startup public
static function import ($alias, $ Forceinclude=false)//class Import public
static function createcomponent ($config)//Create component public
static function Setapplication ($app) //Create Instance of Class Yii::app ()
Two automatic loading mechanism
There are more important yii automatic loading mechanism, at the end of Yiibase referenced PHP standard library function Spl_autoload_register (array (' yiibase ', ' autoload ')) invoke the AutoLoad method in the frame
/** * Class autoload loader.
* This are provided to be invoked within a __autoload () Magic method. * @param string $className class name * @return Boolean whether the class has been loaded successfully/PU Blic static function AutoLoad ($className) {//use include So, the error PHP file may appear if
Set (self:: $classMap [$className])) include (self:: $classMap [$className]);
else if (isset (self::$_coreclasses[$className)) include (yii_path.self::$_coreclasses[$className]); else {//include class file relying on Include_path if (Strpos ($className, ' \ \ ') ===false)
Class without namespace {if (self:: $enableIncludePath ===false) { foreach (self::$_includepaths as $path) {$classFile = $path. Directory_separator. $className.
PHP '; if (iS_file ($classFile)) {include ($classFile);
Break else include ($className. ').
php '); else//class name with namespace in PHP 5.3 {$namespace =str_replace (' \ \ ', '. ')
, LTrim ($className, ' \ n ')); if ($path =self::getpathofalias ($namespace))!==false) include ($path. ').
php ');
else return false; Return Class_exists ($className, false) | |
Interface_exists ($className, false);
return true; }
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/PHP/