Mohamed Zouine
Mohamed Zouine

Reputation: 66

Using DOMPDF in Laravel10

After the installation process is finished, in order to properly register the service provider and alias, you should insert the following lines into the config/app.php file:

'providers' => ServiceProvider::defaultProviders()->merge([
    // ...
    Barryvdh\DomPDF\ServiceProvider::class,
],

'aliases' => Facade::defaultAliases()->merge([
    // ...
    'PDF' => Barryvdh\DomPDF\Facade::class,
],

However, it is important to note that an error may occur indicating that 'Barryvdh\DomPDF\Facade' is an Undefined type.

I have verified that the domPDF package has been successfully installed.

Upvotes: -1

Views: 100

Answers (1)

Shraddha Patel
Shraddha Patel

Reputation: 146

INSTEAD OF

'PDF' => Barryvdh\DomPDF\Facade::class,

USE

'PDF' => Barryvdh\DomPDF\Facade\Pdf::class,

INSIDE YOUR CONTROLLER:

use Illuminate\Support\Facades\File;

$pdf = Pdf::loadView('pdf_view', $data);

Upvotes: 1

Related Questions