Home  >  Article  >  PHP Framework  >  How to solve the problem that thinkphp module does not exist

How to solve the problem that thinkphp module does not exist

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-08-26 13:45:0713104browse

How to solve the problem that thinkphp module does not exist

How to solve the problem that thinkphp module does not exist?

Solution:

1. Add the "EmptyBaseController.class.php" file in the \application\Common\Controller directory.

<?php/**
*@Author:HTL
*@Email:Huangyuan413026@163.com
*@DateTime:2015-07-1411:22:18
*@Description:空模板控制器
*@use:其他项目添加EmptyController文件并继承该类即可
*/namespace Common\Controller;useThink\Controller;class EmptyBaseController extendsController{function_initialize()
{//项目配置文件中的配置项
$emptyPath=C("EMPTY_PATH");//如果未配置默认的地址
if(!$emptyPath || empty($emptyPath))$emptyPath="/";header("Location:".$emptyPath);exit();
}
}

Related recommendations: "ThinkPHP Tutorial"

2. Add EmptyController.class.php in the Controller directory of all projects and inherit "\Common\Controller\EmptyBaseController ".​ ​ ​ ​ ​

<?php/**
*@Author:HTL
*@Email:Huangyuan413026@163.com
*@DateTime:2015-07-1411:22:18
*@Description:空模板控制器,直接继承\Common\Controller\EmptyBaseController即可
*/namespace Portal\Controller;class EmptyControllerextends \Common\Controller\EmptyBaseController{
function _initialize(){
parent::_initialize();
}
}

3. Add the "EMPTY_PATH" item in \data\conf\config.php to customize the page that needs to be jumped when accessing a module that does not exist.         

<?php return array(&#39;EMPTY_PATH&#39;=>&#39;/index.php&#39;,/*访问不存在的模块时跳转的地址*///其他配置项);?
>

The above is the detailed content of How to solve the problem that thinkphp module does not exist. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn