I'm using laravel 9 and my PhP version is 8.0.2 and I'm trying to install the Mpdf package, so I wrote the following command
composer require mpdf/mpdf
but I get this error Question 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.
I tried removing the vendor and composer.lock and updating with composer and it did work
mPDF is not compatible with
psr/log
3.x because it supports older PHP versions (without return type hints). A previous installation of Laravel will force thepsr/log
library to be converted to the 3.x version.You can use the flags
--with-all-dependencies
andcomposer require mpdf/mpdf
to automatically downgrade dependencies.Alternatively, downgrade the
psr/log
library to 2.x - just add or change the"psr/log": "^2.0"
line in your Composer. json file and runcomposer update
. This will solve the problem.Or you can ask for mPDF first and then ask for Laravel, which should work too. Or require them both in one command.