现有这个文件
\tp\application\index\controller\Controller1.php
用这个 url 可以正常访问, 不报错
http://tp/index/controller1/func1
想实现文件这样存放, 多一级子目录(子模块)
\tp\application\index\module1\controller\Controller1.php
但是用这个 url 访问会报错
http://tp/index/module1/controller1/func1
报错信息
控制器不存在:app\index\controller\Module1
|      15bb864e1fc775087 OP 能不能做到 以及 要怎么做才行 | 
|  |      2qiayue PRO 是不是少了一级目录 http://tp/index/module1/controller/controller1/func1 | 
|      35bb864e1fc775087 OP @qiayue #2 你这个 URL 打开报一样的错误"控制器不存在:app\index\controller\Module1",URL 中间的“controller”,TP 框架会自动补充 | 
|      45bb864e1fc775087 OP 没人回复,这个问题无解么? | 
|      5loongk      2020-07-27 12:40:58 +08:00 http://tp/index/module1.controller1/func1 | 
|      6fengshils      2020-07-27 12:46:23 +08:00 推荐使用命令行创建子模块控制器,盲猜是命名空间没写对 | 
|      75bb864e1fc775087 OP @loongk #5 报错“控制器不存在:app\index\controller\module1\Controller1” | 
|      85bb864e1fc775087 OP @fengshils #6 命名空间我有专门检查过,还是一样。我觉得主要是因为 TP 框架会自动在类名 app\index 后面加上"controller",导致类名成了 app\index\controller\module1\controller\Controller1  但是正确的类名是 app\index\module1\controller\Controller1 | 
|      9fengshils      2020-07-27 13:39:18 +08:00 试试 ``` php think make:controller index/Controller/Module1/Controller1 ``` | 
|      105bb864e1fc775087 OP 执行后会生成这个文件   \tp\application\index\controller\Controller\Module1\Controller1.php 然后用这种方式访问到控制器 http://tp/index/controller.Module1.Controller1/index 但和我要的不一样,我要的是这样 \tp\application\index\module1\controller\Controller1.php 最后没办法的话,我也只能这样用了,把 module1 子模块的文件放在“\tp\application\index\controller”里面用了 | 
|      11fengshils      2020-07-27 14:09:06 +08:00 .的话好像不支持把,估计你得改源代码了 | 
|      12back0893      2020-07-27 14:31:17 +08:00 直接写路由不就好了 | 
|  |      13doublie      2020-07-27 14:31:50 +08:00 Route::get('index/module1/controller1/func1', 'index/module1.Controller1/func1'); 这样配置一下路由不知道行不行 | 
|      145bb864e1fc775087 OP | 
|  |      15cnoder      2020-07-27 17:40:11 +08:00 路由也不是每个接口都要写,可以只给这个子模块的配置路由 | 
|      16absolutelynull      2020-07-27 17:53:43 +08:00 \tp\application\index\controller\module1\Controller1.php index.module1/controller1 | 
|      175bb864e1fc775087 OP @absolutelynull #16  本来我想要的是 \tp\application\index\module1,目测是没法实现了 只能用跟你说的这种把子模块放在 index\controller 里的 \tp\application\index\controller\module1 方式了 | 
|  |      18akagishigeru      2020-07-27 22:14:31 +08:00 via iPhone 没办法的 你看源码就会发现的 写死的规则 | 
|      19absolutelynull      2020-07-29 09:10:19 +08:00 @5bb864e1fc775087 url 访问控制器的话 只能访问到 controller 下面的目录文件 不然的话 就不会出现 controller model view 这几个目录了 |