phpmpdf

Mpdf\Mpdf LoggerAwareInterface incompatibility with Psr\Log in php 8.1.12


I get the following error when trying to use mpdf:

Declaration of Mpdf\Mpdf::setLogger(Psr\Log\LoggerInterface $logger) 
must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void 

The most information I can find on the topic is this but I can't find how to fix it.

There is mention of using the branch php8-support but I tried this and it doesn't work either.

Has anyone found a work around on this?

I am on php 8.1.12 and using "mpdf/mpdf": "v8.0.13"


Solution

  • Update 2023/05/03: Update mPDF to version 8.1.6, where psr/log 3.x is supported and this message should not be present.


    Versions and branches of mPDF have nothing to do with this.

    mPDF is not compatible with psr/log 3.x because of support of older PHP versions (which do not have return type hints).

    One or more of your dependencies, or yourself, are forcing psr/log library to version 3.x. You can find out which by calling composer why psr/log in the console.

    Downgrade the psr/log library to 2.x - just enter/change "psr/log": "^2.0" line in your composer.json file and run composer update. This should resolve the issue.

    If any of your libraries enforce psr/log 3.x (do not allow lower major versions), the composer update call will fail and you will have to either downgrade or replace these libraries, or not use mPDF.