希望对 配置 route.controller_suffix 配置作兼容
Closed this issue · 2 comments
bylar commented
如果开启了thinkphp的 配置:
配置说明
// 开启控制器后缀
'controller_suffix' => true,
对应文件 /app/api/controller/IndexController 自动适配的地址就变成了 /api/indexController
而不是 /api/index
所以希望可以通过实时读取配置,或者在配置文件中主动配置的方式来兼容这种后缀模式。
bylar commented
目前的一种解决方案是
修改 auto_url.custom
配置:
// (选配)自定义url生成方法
'custom' => function ($path, $method) {
$pathArr = explode("\\", $path);
$moduleName = lcfirst($pathArr[1]);
$controllerName = lcfirst(str_replace('Controller', '', $pathArr[3]));
return "/$moduleName/$controllerName/$method";
},
HGthecode commented
你好,由于v4版本并不止兼容tp框架,所以对某一框架特有的一些配置和功能没有直接内置去兼容。
apidoc内置生成url的方法仅为最基础的生成方式,考虑到很多同学对url的生成有各种各样的需求,我不想把内置的方法写得太臃肿;所以此类问题可以通过如你上述说的 自定义来实现。后续我也会在文档的 常见问题类下,写一篇自定义url生成的说明,以及把一些常用的生成规则作为示例,供大家参考。