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
相关产品推荐
相关产品推荐

