Code Monkey home page Code Monkey logo

ci-with-module's Introduction

#CI VERSION 3.1.6

#1、添加常量,在application/config/constanst.php文件末尾添加

define( 'MANAGER_PATH', 'Manager' );
define( 'MODULE_NAME', 'modules' );
define( 'MODULE_PATH', APPPATH . MODULE_NAME . DIRECTORY_SEPARATOR );
define( 'MODULE_CONTROLLER', 'Module_Controller' );

2、增加application/core/MY_Loader.php

<?php
/**
 * Created by Aaron Zhang.
 * Date: 2017/12/19 22:25
 * FileName : MY_Loader.php
 */

class MY_Loader extends CI_Loader
{
	/**
	 * List of paths to load views from
	 * @var    array
	 */
	protected $_ci_view_paths = [ VIEWPATH => true, MODULE_PATH => false ];

	public function __construct ()
	{
		parent::__construct();
	}

	public function initialize ()
	{
		parent::initialize();
	}
}

#3、修改system/core/CodeIgniter.php

>>> 找到如果代码:
    if(empty($class) OR !file_exists(MODULE_PATH . $class . '/controllers/'.$RTR->directory.$class.'.php')){
        $e404 = TRUE;
    }
>>> 在后面添加如下代码:
    if(file_exists(MODULE_PATH . $class . '/controllers/'.$RTR->directory.$class.'.php')){
        $e404 = false;
        require_once(MODULE_PATH . $class . '/controllers/'.$RTR->directory.$class.'.php');
        if(!method_exists($class, $method)){
            $params = array($method, array_slice($URI->rsegments, 2));
            $method = '_remap';
        }
    }

#4、增加类文件

文件 application/libraries/Tpl.php

ci-with-module's People

Contributors

zl0314 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.