thinkphp3.2.2 Common class architecture problem, thinkphp3.2.2 common _php Tutorial

Source: Internet
Author: User

thinkphp3.2.2 Common class schema problem, thinkphp3.2.2 public


Before 3.13 Many projects all use the front and back common class, under Lib/action creates the baseaction as the public inherits the class, discovers 3.2.2 inside many people all use a call, so every use once to use a call, good trouble, small part deliberately lazy. The pro-test is resolved using the following methods. Welcome to Strengthen

thinkphp3.2.2 's so created application/common/controller/basecontroller.class.php

 
 1 
   PHP 2namespace Common\controller; 3  Use Think\controller; 4     /* * 5     * Front and rear common base class 6    * Modify Author:jack  7    * Modify time:201 4-7-12  8     * / 9     classextends  Controller {ten-one public                  function _initialize () {// Global Variables  a                Dump (' base class ');  -             $this, CFG ();  -         }      

In the home/controller/zixuncontroller.class.php

 
  Phpnamespace Home\controller;  Use Common\controller\basecontroller; class extends Basecontroller {    publicfunction  index () {        $result$ this, lists ();        Dump ($result);}    }

Of course, in front of the background can also create their own base class, such as the background built AdminController.class.php inherit BaseController.class.php, The foreground creates HomeController.class.php inheritance BaseController.class.php each module inherits its own base class, so the project can be clearer, avoids duplicating wheels, saves a lot of things, but it must be noted that each class must declare a namespace, but the resources used can After being defined in the respective base class, you do not have to write once. For example, AdminController.class.php inherit BaseController.class.php, you do not have to write the use of Think\controller, directly using uses Common\controller\ Basecontroller can do it.

http://www.bkjia.com/PHPjc/916820.html www.bkjia.com true http://www.bkjia.com/PHPjc/916820.html techarticle thinkphp3.2.2 Common class schema problems before and after thinkphp3.2.2 public 3.13 Many projects use both front and back common classes, create baseaction as public inheriting classes under Lib/action, Discover ...

  • 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.