You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 9中安装mPDF包失败的问题及解决办法

问题

使用Laravel 9框架、PHP 8.0.2环境,执行composer require mpdf/mpdf安装mPDF包时触发依赖冲突错误:

Problem 1
    - mpdf/mpdf[v8.1.0, ..., v8.1.2] require psr/log ^1.0 || ^2.0 -> found psr/log[1.0.0, ..., 1.1.4, 2.0.0] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires mpdf/mpdf ^8.1 -> satisfiable by mpdf/mpdf[v8.1.0, v8.1.1, v8.1.2].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
解决步骤
  • 删除项目根目录下的vendor目录
  • 删除项目根目录下的composer.lock文件
  • 执行命令:composer update

执行完成后,mPDF包可正常安装,依赖冲突问题解决。

内容的提问来源于stack exchange,提问作者Shady Hesham

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 21:50:22