This article mainly introduces ThinkPHP3.2.2 plug-in controller function. If you need ThinkPHP, refer to ThinkPHP to support calling of plug-in controller from version 3.2.2, 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:
http://serverName/Home/info/index/addon/SystemInfo
Because the addon parameter is passed in, the User controller here is not the original
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
Home/Addon/SystemInfo/Controller/InfoController.class.php
The plug-in controller itself is defined like a common access controller, for example:
namespace Home\Addon\SystemInfo\Controller; class InfoController extends \Think\Controller{ public function index(){ echo 'Addon SystemInfo'; } }
In this way, we are accessing
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:
'VAR_ADDON' => 'plugin'
Then the access URL becomes
http://serverName/Home/info/index/plugin/SystemInfo
Note that:Currently, the plug-in controller only supports module plug-in Controller Access and does not support global public plug-ins.