LoggerAwareInterface Not Found in mPdf

Hello I am using Core PHP And my requirement is To create a pdf from database data using simple php. i dont have much knowledge on composer and packegist and all.i just wants an convert php table to pdf. for that i am using php Mpdf. And i am Reffering This tutorial. It says:

//include the library class mPDF at the end of the index.php file.
$mpdf = new mPDF();

//call watermark content aand image
$mpdf->showWatermarkText = true;
$mpdf->watermarkTextAlpha = 0.1;

//save the file put which location you need folder/filname
$mpdf->Output("phpflow.pdf", 'F');

//out put in browser below output function

But after including it throws an error

Interface 'Psr\Log\LoggerAwareInterface' not found on line 56

So how can i resolve this. on github documentation it suggest to add

require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<h1>Hello world!</h1>');

But as i download the plugin it dowes not have any folder with name vendor.

1 answer

  • answered 2018-04-24 09:28 Finwe

    Use composer as the tutorial suggests to fetch mpdf as a dependency and build autoloading:

    composer require mpdf/mpdf

    or use mPDF 6.x version which does not require these dependencies.

    Note that

    $mpdf = new \Mpdf\Mpdf();

    is the constructor for 7.x version, use

    $mpdf = new mPDF();

    for 6.x only.