ThinkPHP3.2.2 plug-in controller function brief _ php instance

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

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.