The most common service locator is an application object. You can use Yii: $ app to access the most common service locator is an application object. You can use \ Yii :: $ app access
Reply content:
The most common service locator is the application object, which can be accessed through \ Yii: $ app
You can see the source code. If your application is a web application, in index. php
(New yii \ web \ Application ($ config)-> run ();
Call the construction method of the Application, and it inherits fromYii \ base \ Application
The constructor is
Public function _ construct ($ config = []) {Yii: $ app = $ this; $ this-> setInstance ($ this); $ this-> state = self:: STATE_BEGIN; $ this-> preInit ($ config); $ this-> registerErrorHandler ($ config); Component ::__ construct ($ config );}
In the subsequent instantiation process, you can view the source code in order. If you have any questions, please leave a message and check the source code to help you quickly understand the initialization and running process of yiiframework.
This is a magic variable!