thinkphp5.1单模块设置

thinkphp5.1单模块

1、
// 是否支持多模块
'app_multi_module' => false,
// 自动搜索控制器
'controller_auto_search' => true,
2、
去掉application目录下的 Index 文件夹,
在这里目录下创建controller、model、view三个目录(可以先只创建controller,用到的时候在创建其他的)

3、修改文件route/route.php
把默认的Route::get('hello/:name', 'index/hello'); 注释掉

4、
修改controller目录下默认Index类的命名空间: namespace appcontroller;

4、在application目录下新建一个类Study

class Study
{
    public function index()
    {
        return "study";
    }

    public function testStudy($name)
    {
        return "testStudy +++ " . $name;
    }
}

  

5、访问http://localhost:8090/study/testStudy/name/hello
输出testStudy +++ hello

6、访问http://localhost:8090
默认访问的是Index控制器的index方法

原文地址:https://www.cnblogs.com/ZhYQ-Note/p/10712641.html