thinkphp5.1、thinkphp6
2022-11-24 11:10:29
176
{{single.collect_count}}

下载原装:https://packagist.org/packages/topthink/think

composer create-project topthink/think tp 6.0.*-dev

文档地址

5.1取消了所有的系统常量

5.1新特性

容器、门面、中间件

 

 控制器支持模型的依赖注入

//需要use user的命名空间
public
function demo(User $user){$user->db()->find(uid:4); }

aplication 目录变为app

view视图层从app同级且需要手动引入think\view视图类

namespace app\index\controller
use
think\facade\View;class Index{public function index(){// 模板变量赋值View::assign('name','ThinkPHP');View::assign('email','thinkphp@qq.com');// 或者批量赋值View::assign(['name'=> 'ThinkPHP','email' => 'thinkphp@qq.com']);// 模板输出return View::fetch('index');}}

对用模版文件 view/index/index.html

 

配置文件细化

 

6.0(5.2):改变细节

应用目录将aplication改为app

核心类库有thinkphp移至vendor

取消了原本的think\Loader

...

 

转载于:https://www.cnblogs.com/lichihua/p/11296661.html

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}