KnpLabs / snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage
https://knplabs.com
MIT License
4.4k stars 436 forks source link

PSR Logging interface error #443

Closed bvanleeuwen1995 closed 2 years ago

bvanleeuwen1995 commented 3 years ago

In file AbstractGenerator.php the setLogger function is incompatibly with the latest psr/log version. This version implemented function return types in the interface and will throw the following error: Declaration of Knp\Snappy\AbstractGenerator::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void

Downgrading to psr/log version 2.0.0 fixes this problem. Fixing this will probably require a major version update since an API change is needed, if necessary I can create a PR if

still-dreaming-1 commented 3 years ago

I'm running into this issue in a production environment. Is there a recommended workaround for now? Do you think downgrading to a previous release would fix it? I'm on v1.3.1.

still-dreaming-1 commented 3 years ago

I had to downgrade to snappy v1.2.1

bvanleeuwen1995 commented 3 years ago

@still-dreaming-1 you can use the latest version of snappy (1.3.1), however just add psr/log@2 to composer.json file in order to downgrade the logging package.

bvanleeuwen1995 commented 3 years ago

Basically in 1.3.1 the psr/log version string allows the installation of version 3, which has breaking API changes apparently (which is to be expected with a major version update). But also allows older major versions thats why the downgrading of psr/log works.

still-dreaming-1 commented 2 years ago

What I'm understand is, the latest release has a very serious regression bug by trying to allow use of psr/log version 3 even though they are not compatible. I can see how supporting the latest major version of psr/log is ideal. However, if currently snappy is incompatible with version 3, I think the first step is to change snappy's composer.json file to accurately indicate which versions of psr/log it is compatible with. Then a new, non-broken release should go out. Projects using this should not need to add an explicit version of psr/log to depend on if they are not using it otherwise just to get snappy to work. After that release goes out, then work on supporting psr/log version 3 can happen any time.

alexpozzi commented 2 years ago

Sorry for the inconvenience but I don't have much time to dedicate to this project at the moment. I'm gonna try to work on it later this week.

Mohammed-Samour-pr commented 2 years ago

Most likely there will be a compatibility issue with the package (mpdf) version and the language(PHP) version After several attempts, the compatibility between Jazm and language(PHP) was discovered as follows.

mPDF >=7.0 is supported on PHP ^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0 PHP 7.3 is supported since mPDF v7.1.7 PHP 7.4 is supported since mPDF v8.0.4 PHP 8.0 is supported since mPDF v8.0.10 PHP 8.1 is supported as of mPDF v8.0.13

If you have trouble installing the package, use the following command

composer require mpdf/mpdf:^version -w

Note: Put the word “version” instead (the version that matches your version)

Good luck everyone......