ThinkPHP3.2.2 _php instance of plug-in controller function

Source: Internet
Author: User

The 3.2.2 version begins to support calls to the plug-in controller, which can be accessed through a more convenient URL address to a plug-in-defined controller in the module.

The action method in the plug-in controller is automatically positioned when the plug-in controller variable is passed in to the URL.

The variables for the plug-in controller are set by the parameter Var_addon, and the default is ADDON, for example, we pass in the URL:

Copy Code code as follows:

Http://serverName/Home/info/index/addon/SystemInfo

Because the addon parameter is passed in, the user controller here is not the original

Copy Code code as follows:

home/controller/infocontroller.class.php

Instead, it calls the Infocontroller controller of the SystemInfo plug-in (located under the Home/addon directory), which is located in the

Copy Code code as follows:

home/addon/systeminfo/controller/infocontroller.class.php

The plug-in controller itself is defined as the normal access controller, for example:

Copy Code code as follows:

namespace Home\addon\systeminfo\controller;
Class Infocontroller extends \think\controller{
Public Function index () {
Echo ' Addon systeminfo ';
}
}

In this way, we are visiting

Copy Code code as follows:

Http://serverName/Home/info/index/addon/SystemInfo

, it will output
Addon SystemInfo
If our plugin directory is not addon, but plugin, then you need to define in the configuration file:

Copy Code code as follows:

' Var_addon ' => ' plugin '

And then access the URL address becomes

Copy Code code as follows:

Http://serverName/Home/info/index/plugin/SystemInfo

Note: The plug-in controller currently supports only the plug-in controller access for the module, and global public plug-ins are not yet supported.

Note: This usage is only for the 3.2.2 version downloaded from the website. Subsequent adjustments will be made in detail, including defining the plug-in location, and so on.
For more usage, please refer to the details of the following 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.