thinkphp 8安装后必须立即检查依赖完整性,否则必报driver [think] not supported等错误;因框架模块彻底拆分,think-view、think-orm等需手动安装,仅靠composer create-project仅得骨架,须用composer show验证vendor中实际包,再以php think version/env确认加载成功。

ThinkPHP 8 安装后必须立刻检查依赖是否完整,否则运行时大概率报错,比如 Driver [Think] not supported 或 Class not found。这不是“可能出问题”,而是几乎必然发生——因为 ThinkPHP 8 的模块拆分太彻底,topthink/think-view、topthink/think-orm 这些不再是框架内置,全靠手动装。
用 composer show 看已装了哪些包
这是最直接的起点,不依赖任何配置或运行环境,纯看 vendor 目录现状:
- 在项目根目录执行
composer show,列出所有已安装的包及其版本 - 重点盯住
topthink/开头的包:比如topthink/framework(必须有)、topthink/think-view(视图驱动)、topthink/think-orm(模型层) - 如果只看到
topthink/framework,其他全是第三方包(如monolog/monolog),说明核心扩展一个没装,后续必崩
用 composer show -t 查依赖树,确认是否被间接拉入
有些包看似没装,其实是被其他依赖“顺带”装进来的。但 ThinkPHP 8 不鼓励这种隐式依赖,所以必须显式验证:
- 执行
composer show -t topthink/framework,看它是否声明了对topthink/think-view的 require - 实际结果是:ThinkPHP 8 的
topthink/framework已移除所有 view / orm / cache 等组件的硬依赖,show -t输出里不会出现这些子包 - 这意味着:哪怕你
composer create-project topthink/think tp8新建项目,也只装了框架骨架,view、orm、queue全得自己补
用 composer why-not 快速定位缺失驱动的根源
当报错 Driver [Think] not supported 时,不是代码写错了,而是 think-view 没装。但你怎么确认就是它?
- 先试运行:访问一个带模板渲染的路由,触发错误
- 然后执行
composer why-not topthink/think-view - 输出会明确告诉你:
There is no installed package depending on "topthink/think-view"—— 即没人要求它,所以它不存在 - 这个命令比翻日志快得多,特别适合 CI/CD 流水线中做自动化依赖校验
用 php think version 和 php think env 验证框架是否真正加载成功
装完依赖不等于框架能跑通。这两个命令是最后的“握手测试”:
-
php think version应该输出类似v8.0.4,而不是报Class 'think\Console' not found—— 后者说明 autoloader 没生效或topthink/framework装损毁 -
php think env会打印当前环境配置,如果报Driver [Think] not supported,就坐实是think-view缺失;如果报Class 'think\db\Connection' not found,则是think-orm没装 - 注意:这两个命令必须在 PHP 8.0+ 环境下运行,
php -v不达标时,php think会静默失败或抛出奇怪的解析错误
最容易被忽略的一点:ThinkPHP 8 的依赖检查不能只看 composer.json 里写了什么,而要看 vendor/ 里真有什么。很多团队把 composer.lock 提交到 Git,却忘了 CI 机器上执行的是 composer install --no-dev,而某些驱动包被误放在 require-dev 里——结果线上环境永远缺关键组件。
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!











