There are two base classes that almost everything in Yii2 extends from: the
Component class and the
In Yii2, the
Component class has replaced the
CComponent class from Yii1. In Yii1, components act as service locators that host a specific set of application components that provide different services for the processing of requests. Each component in Yii2 can be accessed using the following syntax:
For example, the database component can be accessed using this:
The cache component can be accessed using this:
Yii2 automatically registers each component at runtime via the application configuration that we mentioned in the previous section by name.
To improve ...