新版支持任意层次级别的控制器,并且支持路由,例如:

namespace app\index\controller\one;use think\Controller;class Blog extends Controller{    public function index()
    {        return $this->fetch();
    }    
    public function add()
    {        return $this->fetch();
    }    
    public function edit($id)
    {        return $this->fetch();
    }
}

该控制器类的文件位置为:

application/index/controller/one/Blog.php

访问地址可以使用

http://serverName/index.php/index/one.blog/index

如果要在路由定义中使用多级控制器,可以使用:

\think\Route::get('blog/add','index/one.Blog/add');


 小秋同学  控制器  2021-03-24 09:46:27    收藏:  赞(871)
学习吧_一个不错的学习网站
本文地址:https://www.qiuhai.com/doc/1601.html 复制链接 如果还有疑问,欢迎加入我们的QQ交流群:887790 加入Q群 易优最新程序下载: 点击下载
QQ在线咨询