I'm trying to integrate the barryvdh/laravel-dompdf package into my Laravel 10 project. After installing it via Composer:
composer require barryvdh/laravel-dompdf
I followed the documentation and manually added the service provider and alias in config/app.php:
'providers' => ServiceProvider::defaultProviders()->merge([
Barryvdh\DomPDF\ServiceProvider::class,
]),
'aliases' => Facade::defaultAliases()->merge([
'PDF' => Barryvdh\DomPDF\Facade::class,
]),
But when I try to use it, I get the following error:
Undefined type 'Barryvdh\DomPDF\Facade'
What I’ve Checked:
use Barryvdh\DomPDF\Facade as PDF;
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);