This article mainly introduces how to use the plug-in controller functions supported by ThinkPHP3.2.2, which is very detailed. we recommend this article to our friends. 3.2.2 versions support calling plug-in Controllers. you can access the controller defined by a plug-in the module through a more convenient URL address.
When the plug-in controller variable is input in the URL, the operation method in the plug-in controller is automatically located.
The variables of the plug-in controller are set by the VAR_ADDON parameter. the default value is addon. for example, we input the following variables in the URL:
The code is as follows:
Http: // serverName/Home/info/index/addon/SystemInfo
Because the addon parameter is passed in, the User controller here is not the original
The code is as follows:
Home/Controller/InfoController. class. php
Instead, call the InfoController controller of the SystemInfo plug-in (located under the Home/Addon directory). The file is located in
The code is as follows:
Home/Addon/SystemInfo/Controller/InfoController. class. php
The plug-in controller itself is defined like a common access controller, for example:
The code is as follows:
Namespace Home \ Addon \ SystemInfo \ Controller;
Class InfoController extends \ Think \ Controller {
Public function index (){
Echo 'addon systeminfo ';
}
}
In this way, we are accessing
The code is as follows:
Http: // serverName/Home/info/index/addon/SystemInfo
Will output
Addon SystemInfo
If our plug-in directory is not Addon but Plugin, we need to define it in the configuration file:
The code is as follows:
'Var _ addon' => 'plugin'
Then the access URL becomes
The code is as follows:
Http: // serverName/Home/info/index/plugin/SystemInfo
Note: Currently, the plug-in controller only supports access from the plug-in controller of the module, and does not support global public plug-ins.
Note: This method is only applicable to version 3.2.2 downloaded from the official website. Some details will be adjusted in the future, including defining the plug-in location.
For more usage instructions, refer to the subsequent detailed manual.