我使用的是laravel 9,我的PhP版本是8.0.2,我正在嘗試安裝Mpdf包,所以我編寫了以下命令
composer require mpdf/mpdf
但我收到此錯誤 問題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.
我嘗試刪除供應商和composer.lock并使用composer更新,它確實有效
mPDF 與 psr/log
3.x 不兼容,因為它支持較舊的 PHP 版本(沒有返回類型提示)。
之前安裝的 Laravel 會強制將 psr/log
庫轉(zhuǎn)換為 3.x 版本。
您可以使用標志 --with-all-dependencies
以及 composer require mpdf/mpdf
自動降級依賴項。
或者,將 psr/log
庫降級到 2.x - 只需在您的 Composer 中添加或更改 "psr/log": "^2.0"
行。 json 文件并運行 composer update
。這將解決該問題。
或者你可以先要求 mPDF,然后再要求 Laravel,這也應該可以?;蛘咴谝粋€命令中同時要求它們。