Use of plug-in controller under TP
Thinkphp from the 3.2.2 Release to support the call of the plug-in controller, can be accessed through a more convenient URL address to the module of a plug-in-defined controller .
When a plugin controller variable is passed in the URL, it is automatically positioned to the action method in the plug-in controller.
For example, http://domain/app/admin/index/addon/Newhongbao
The actual access is under the domain name | | Addon under the root directory
Directory structure
/addons
|__Newhongbao
|__controller
|__AdminController.class.php
Note: Index.php/home/index/index/addon/hongbao to access results
First step: import file Definition
Define (' Addon_path ', ' Addons ');
Step two: Automatically load namespaces in/application/common/conf/conf.php configuration
' Autoload_namespace ' = Array (
),
Step Three: Operation addons/hongbao/controller/indexcontroller.class.php
<?php
namespace Addons\hongbao\controller;
Class Indexcontroller extends \think\controller{
Public Function index () {
Header ("Content-type:text/html;charset=utf8");
Echo ' This is a plugin system ';
}
}
Fourth Step: Test
Visit Http://localhost/tp/index.php/Home/index/index/addon/Hongbao
Output
This is a plug-in system
Use of the plug-in addon under TP (thinkphp)