Home > Mobile >  PHP Fatal error: Uncaught Error: Class "Mpdf\Mpdf" not found in C:\xampp\htdocs\server
PHP Fatal error: Uncaught Error: Class "Mpdf\Mpdf" not found in C:\xampp\htdocs\server

Time:04-10

PHP Fatal error: Uncaught Error: Class "Mpdf\Mpdf" not found in C:\xampp\htdocs\server\pdf.php:5 Stack trace: #0 {main} thrown in C:\xampp\htdocs\server\pdf.php on line 5

PHP 8.1.3, PHP Intelephense v1.8.2

compser.json

{
"require": {
    "mpdf/mpdf": "^6.1"
      }
}

composer.lock

{
    "name": "mpdf/mpdf",
    "version": "v6.1.2",
    "source": {
    "type": "git",
    "url": "https://github.com/mpdf/mpdf.git",
    "reference": "da078bc2669d3f98553ac41f920ead4c17c951ad"
        },

pdf.php

<?php

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

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

What I am doing wrong? What I am not understanding?

Thank you for your help!

enter image description here

CodePudding user response:

require path need update to :

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

Make sure that the library exists at vendor if not run composer update

CodePudding user response:

@Omar Tammam Can you give me a contact that can contact you, thanks in advance

  • Related