laravel-dompdf
laravel-dompdf copied to clipboard
DomPDF\Facade not found Error - Laravel 9
Recently I upgraded my Laravel to ver 9.20.0 which brings this err
Class "Barryvdh\DomPDF\Facade" not found
I have included it in the providers
Barryvdh\DomPDF\ServiceProvider::class,
and aliases too
'DPDF' => Barryvdh\DomPDF\Facade::class,
Please help.
run composer show
and see what version you have installed
Facade was deprecated and removed, read changelog or documentation
i always fail to use barryvdh/laravel-dompdf on my laravel 9. the route always not found.
@Kuroyasha11 this package dont use routes
In the process of upgrading from Laravel 8.35
to Laravel 9.19,
I also upgraded:
"barryvdh/laravel-dompdf": "^0.9.0",
To
"barryvdh/laravel-dompdf": "^2.0.0",
Then I received this error:
Class "Barryvdh\DomPDF\Facade" not found {"userId":12,"exception":"[object] (Error(code: 0): Class \"Barryvdh\\DomPDF\\Facade\" not found.
Following @erikn69's recommendation in a comment, I inspected my controller and solved this issue using:
Instead of: ❌
use Barryvdh\DomPDF\Facade as DomPDF;
class StudentController extends Controller
{
function downloadStudentList() {
return DomPDF::loadView(...);
}
}
Use this: ✅
use Barryvdh\DomPDF\Facade\Pdf;
class StudentController extends Controller
{
function downloadStudentList() {
return Pdf::loadView(...);
}
}
use Barryvdh\DomPDF\Facade\Pdf as PDF;
class StudentController extends Controller
{
function downloadStudentList() {
return PDF::loadView(...);
}
}
On latest update package has changed it name.
https://github.com/barryvdh/laravel-dompdf/blob/9843d2be423670fb434f4c978b3c0f4dd92c87a6/readme.md?plain=1#L36-L41
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/dompdf/dompdf instead. When having doubts, please try to reproduce the issue with just dompdf. If you believe this is an actual issue with the latest version of laravel-dompdf, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.