我使用的是laravel 9,我的PhP版本是8.0.2,我正在嘗試安裝Mpdf包,所以我編寫了以下命令
composer require mpdf/mpdf
但我收到此錯(cuò)誤 問(wèn)題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.
我嘗試刪除供應(yīng)商和composer.lock並使用composer更新,它確實(shí)有效
mPDF 與 psr/log
3.x 不相容,因?yàn)樗г^舊的 PHP 版本(沒(méi)有傳回類型提示)。
先前安裝的 Laravel 會(huì)強(qiáng)制將 psr/log
函式庫(kù)轉(zhuǎn)換為 3.x 版本。
您可以使用標(biāo)誌 --with-all-dependencies
以及 composer require mpdf/mpdf
自動(dòng)降級(jí)相依性。
或者,將 psr/log
庫(kù)降級(jí)到 2.x - 只需在您的 Composer 中添加或更改 "psr/log": "^2.0"
行。 json 檔案並執(zhí)行 composer update
。這將解決該問(wèn)題。
或你可以先要求 mPDF,然後再要求 Laravel,這也應(yīng)該可以?;蛟谝粋€(gè)命令中同時(shí)要求它們。