1.关于yii、Yii、$app
BaseYii.php
<?php
namespace yii;
...
/**
* BaseYii is the core helper class for the Yii framework.
*
* Do not use BaseYii directly. Instead, use its child class [[\Yii]] which you can replace to
* customize methods of BaseYii.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class BaseYii
{
...
/**
* @var \yii\console\Application|\yii\web\Application the application instance
*/
public static $app;
...
}
Yii.php
<?php
/**
* Yii bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
require(__DIR__ . '/BaseYii.php');
/**
* Yii is a helper class serving common framework functionalities.
*
* It extends from [[\yii\BaseYii]] which provides the actual implementation.
* By writing your own Yii class, you can customize some functionalities of [[\yii\BaseYii]].
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class Yii extends \yii\BaseYii
{
}
spl_autoload_register(['Yii', 'autoload'], true, true);
Yii::$classMap = require(__DIR__ . '/classes.php');
Yii::$container = new yii\di\Container();
2.yii\bootstrap\ActiveForm 和 yii\widgets\ActiveForm
yii\bootstrap\ActiveForm继承自yii\widges\ActiveForm