niklasravnsborg/laravel-pdf

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

s1k3 opened this issue · 3 comments

s1k3 commented

Describe the bug

PHP Fatal error:  Declaration of Mpdf\Mpdf::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void in /home/robin/Projects/test/vendor/mpdf/mpdf/src/Mpdf.php on line 1569

To Reproduce
Use

  1. Laravel 9**
  2. php 8.1.3
  3. "niklasravnsborg/laravel-pdf": "^4.1"

Code Used to Render Pdf

<?php

use Illuminate\Support\Facades\Route;
Route::get('/', function () {
    $pdf = PDF::loadView('welcome', []);
    return $pdf->stream('document.pdf');
});

HTML used

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
</head>
<body>
<p>This is test</p>
</body>
</html>

I have this problem too

My problem was solved this way

  1. composer remove niklasravnsborg/laravel-pdf
  2. composer remove mpdf/mpdf
  3. composer remove psr/log
  4. composer require psr/log=v2.*
  5. composer require mpdf/mpdf v8.0.17
  6. composer require niklasravnsborg/laravel-pdf
s1k3 commented

@mr-ghomi Thanks a lot. It does resolve the issue