laravel-dompdf icon indicating copy to clipboard operation
laravel-dompdf copied to clipboard

DomPDF\Facade not found Error - Laravel 9

Open shadywattay opened this issue 2 years ago • 9 comments

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.

shadywattay avatar Jul 21 '22 04:07 shadywattay

run composer show and see what version you have installed

delboy1978uk avatar Jul 25 '22 11:07 delboy1978uk

Facade was deprecated and removed, read changelog or documentation

erikn69 avatar Aug 02 '22 03:08 erikn69

i always fail to use barryvdh/laravel-dompdf on my laravel 9. the route always not found.

Kuroyasha11 avatar Aug 14 '22 07:08 Kuroyasha11

@Kuroyasha11 this package dont use routes

erikn69 avatar Aug 14 '22 19:08 erikn69

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(...);
    }
}

steven7mwesigwa avatar Oct 05 '22 12:10 steven7mwesigwa

use Barryvdh\DomPDF\Facade\Pdf as PDF;

class StudentController extends Controller
{
    function downloadStudentList() {
        return PDF::loadView(...);
    }
}

On latest update package has changed it name.

Nutandc avatar Jan 16 '23 09:01 Nutandc

https://github.com/barryvdh/laravel-dompdf/blob/9843d2be423670fb434f4c978b3c0f4dd92c87a6/readme.md?plain=1#L36-L41

erikn69 avatar Jan 16 '23 14:01 erikn69

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.

stale[bot] avatar Jun 18 '23 08:06 stale[bot]