Home > Article > Backend Development > Plug-in controller function of ThinkPHP3.2.2_PHP tutorial
This article mainly introduces how to use the plug-in controller function newly supported by ThinkPHP3.2.2. It is very detailed and recommended here. Friends.
Version 3.2.2 begins to support the calling of plug-in controllers, and you can access the controller defined by a plug-in in the module through a more convenient URL address.
When the plug-in controller variable is passed in the URL, the operation method in the plug-in controller will be automatically located.
The variables of the plug-in controller are set by the parameter VAR_ADDON. The default is addon. For example, we pass it in the URL:
The code is as follows:
The code is as follows:
Instead, the InfoController controller of the SystemInfo plug-in (located under the Home/Addon directory) is called. The file is located at
The code is as follows:
The definition of the plug-in controller itself is the same as that of an ordinary access controller, for example:
The code is as follows:
In this way, we are visiting
The code is as follows:
will be output
Addon SystemInfo
If our plug-in directory is not Addon, but Plugin, then it needs to be defined in the configuration file:
The code is as follows:
Then the access URL address becomes
The code is as follows:
Note: Currently, the plug-in controller only supports module plug-in controller access and does not yet support global public plug-ins.
Note: This usage is only for version 3.2.2 downloaded from the official website. Some detailed adjustments will be made in the future, including defining the location of plug-ins and so on.
For more usage, please refer to the subsequent detailed manual.