Before you do the project, be sure to deploy your own "base class", which is very important. For example, to access the relevant controller in the Member Center, does this type of controller have a "login limit" to access the member-related controllers?
First, create three major base classes
Original base class
Location: thinkphp\apps\common\controller\base.php
Function: The content under the Base module, the index module, and the admin module can all be called
Code:
<?PHP/** * Original base class **/namespaceApp\common\controller;use Think\controller;classBase extends controller{ Publicfunction _initialize () {parent::_initialize (); Echo'Original base class'; } Publicfunction Test1 () {return 'test1'; }}
Index module base class
Location: thinkphp\apps\common\controller\base.php
Function: The controller under the index module, "Inherit base class" and "Call base class"
Code:
<? PHP /* */namespace app\index\controller;use app\common\controller\base; class Indexbase extends base{ public function _initialize () { parent::_initialize (); } Public function index () { }}
Admin module base class
Location: thinkphp\apps\common\controller\base.php
Role: The controller under the admin module, "Inherit base class" and "Call base class"
Code:
/**/namespace app\admin\controller;use app\admin\controller\adminbase; class Index extends adminbase{ public function _initialize () { parent::_initialize () ; Public Function index () { return $ this Fetch (); } }
(User module base class, if there is a member, this also must be created)
The primary purpose of creating a base class is " inherit " and " invoke "
THINKPHP5 Note Three: Create a base class