I am facing "use of unknown class" error when I am using the alias created for facades :: class in my controller.
$pdf = PDF ::loadView('test', $data);
This line says PDF is unknown class.
I have created alias in app.php as
'PDF' => Barryvdh\DomPDF\Facade\Pdf::class,
I tried updating composer, clearing cache, config, etc. doesn't work.
you should not duplicate the code, if you look at the
composer.jsonof the package you will seeextra.laravel.aliaseswhich will add to the list itself. the framework took care of that.You need to take actions:
composer require barryvdh/laravel-dompdfuse Barryvdh/DomPDF\Facade\Pdf;$pdf = Pdf::loadView('pdf.invoice', $data);To make sure you've installed everything correctly, you can run
composer remove barryvdh/laravel-dompdf.rm bootstrap/cache/packages.php.composer dump.