As mentioned above, an application component will only be instantiated when it is being accessed the first time.
如上所述,应用组件只在第一次被访问时实例化。如果在请求期间没有访问组件,它将根本不会实例化。有时候,无论怎样你可能都想为每个请求实例化组件,即便它没有被访问。你可以在应用的 [[yii\base\Application::bootstrap|引导(bootstrap)]] 属性罗列组件 ID 来做到这点。
If it is not accessed at all during a request, it will not be instantiated. Sometimes, however, you may want
to instantiate an application component for every request, even if it is not explicitly accessed.
To do so, you may list its ID in the [[yii\base\Application::bootstrap|bootstrap]] property of the application.
For example, the following application configuration makes sure the `log` component is always loaded:
Yii defines a set of *core* application components with fixed IDs and default configurations. For example,
Yii 定义了一系列拥有固定 ID 和默认配置的**核心**应用组件。例如:[[yii\web\Application::request|请求(request)]]组件被用来收集用户请求数据并解析请求至[路由](runtime-routing.md);[[yii\base\Application::db|数据库(db)]]组件代表一个数据库连接,你可以通过它执行数据库查询。Yii 有赖于这些核心组件的支持去处理用户请求。
the [[yii\web\Application::request|request]] component is used to collect information about
a user request and resolve it into a [route](runtime-routing.md); the [[yii\base\Application::db|db]]