首页 > 技术文章 > Yii::$app

shaoing 2016-03-23 09:07 原文

如果你的应用是一个web应用,其index.php中
(new yii\web\Application($config))->run();
调用Application的构造方法,而其继承自yii\base\Application构造方法为

1 public function __construct($config = [])
2 {
3     Yii::$app = $this;
4     $this->setInstance($this);
5     $this->state = self::STATE_BEGIN;
6     $this->preInit($config);
7     $this->registerErrorHandler($config);
8     Component::__construct($config);
9 }

 

推荐阅读