ThinkPHP3.2.2 plug-in controller function

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.