Preface
The Yii\web\controller class is a more commonly used class, and the Yii2 controller inherits this class. About the Yii\web\controller class, in fact, YII2 document also has, why should I write this article? There may be a lot of people wondering .... I think so, Yii2 the document is there is no mistake, but that is for the public, and there is no instance, let people look at or is more laborious, if someone can read every class, and then release specific examples, is it more comfortable to look at it? Do you understand more quickly?
Demand analysis
Parses the Yii\web\controller class to understand the methods and properties in its class and their use.
Code Analysis
Its order of succession: ' Yii\web\controller? Yii\base\controller? Yii\base\component? Yii\base\object
`
Interfaces implemented:yii\base\ViewContextInterface
Its sub-class:yii\rest\ActiveController, yii\rest\Controller
Taking the Weelysummarycontroller controller as an example, the following is the result of the method or property that I call the parent class for more common use, and is now shared with you:
1, $this->id//Get the name string of the controller (Controller ID)
such as: Weely-summary
2, $this->getViewPath() 或者 $this->viewPath //Get the current view path, specific to the folder name.
Such as:D:\phpStudy\WWW\hand\backend\views\weely-summary
3, $this->action->id//Get the current view name
Example: Index//List page
4, $this->action->actionmethod//Get the current method name
such as: Actionindex
5, $this->actionparams//Bind the parameters of the current operation
such as: Array ([id] = 3)
6, $this->route//Get the route of the current request, get the controller ID and the view ID
such as: Weely-summary/index
Related information
YII2 's Documentation: Http://www.yiichina.com/doc/api/2.0/yii-web-controller
The above describes the analysis of the Yii\web\controller class, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.