Application是所有应用程序类的基类,接下来了解一下它的源码。yii2\base\Application.php。
1 <?php
2 /**
3 * @link http://www.yiiframework.com/
4 * @copyright Copyright (c) 2008 Yii Software LLC
5 * @license http://www.yiiframework.com/license/
6 */
7
8 namespace yii\base;
9
10 use Yii;
11
12 /**
13 * Application is the base class for all application classes.
14 * 是所有应用程序类的基类
15 * @property \yii\web\AssetManager $assetManager The asset manager application component. This property is
16 * read-only.资产管理器应用组件,只读
17 * @property \yii\rbac\ManagerInterface $authManager The auth manager application component. Null is returned
18 * if auth manager is not configured. This property is read-only.认证管理器应用程序组件。未配置返回null,只读
19 * @property string $basePath The root directory of the application. 应用程序的根目录。
20 * @property \yii\caching\Cache $cache The cache application component. Null if the component is not enabled.
21 * This property is read-only.缓存应用程序组件。
22 * @property \yii\db\Connection $db The database connection. This property is read-only.数据库连接。
23 * @property \yii\web\ErrorHandler|\yii\console\ErrorHandler $errorHandler The error handler application
24 * component. This property is read-only.错误处理程序应用程序组件
25 * @property \yii\i18n\Formatter $formatter The formatter application component. This property is read-only.
26 * 格式化程序的应用程序组件。
27 * @property \yii\i18n\I18N $i18n The internationalization application component. This property is read-only.
28 * 国际化应用组件。
29 * @property \yii\log\Dispatcher $log The log dispatcher application component. This property is read-only.
30 * 日志调度程序组件。
31 * @property \yii\mail\MailerInterface $mailer The mailer application component. This property is read-only.
32 * 邮件应用程序组件。
33 * @property \yii\web\Request|\yii\console\Request $request The request component. This property is read-only.
34 * 请求组件。
35 * @property \yii\web\Response|\yii\console\Response $response The response component. This property is
36 * read-only.反应元件。
37 * @property string $runtimePath The directory that stores runtime files. Defaults to the "runtime"
38 * subdirectory under [[basePath]].存储运行时文件的目录。
39 * @property \yii\base\Security $security The security application component. This property is read-only.
40 * 安全应用组件。
41 * @property string $timeZone The time zone used by this application.该应用程序使用的时区。
42 * @property string $uniqueId The unique ID of the module. This property is read-only.模块的唯一标识。
43 * @property \yii\web\UrlManager $urlManager The URL manager for this application. This property is read-only.
44 * 此应用程序的网址管理器。
45 * @property string $vendorPath The directory that stores vendor files. Defaults to "vendor" directory under
46 * [[basePath]].存储供应商文件的目录。
47 * @property View|\yii\web\View $view The view application component that is used to render various view
48 * files. This property is read-only.用于呈现各种视图文件的视图应用程序组件
49 *
50 * @author Qiang Xue <qiang.xue@gmail.com>
51 * @since 2.0
52 */
53 abstract class Application extends Module
54 {
55 /**
56 * @event Event an event raised before the application starts to handle a request.
57 * 在应用程序开始处理请求之前提出的事件。
58 */
59 const EVENT_BEFORE_REQUEST = 'beforeRequest';
60 /**
61 * @event Event an event raised after the application successfully handles a request (before the response is sent out).
62 * 该应用程序成功处理请求后提出的事件
63 */
6