laravel-dompdf: (1/1) ErrorException Non-static method Barryvdh\DomPDF\PDF::loadView() should not be called statically

Laravel 5.4

   $report = XReport::findOrFail($id);

       $pdf = PDF::loadView('patient.report',['report'=>$report]);

       return $pdf->download('invoice.pdf');

(1/1) ErrorExceptionNon-static method Barryvdh\DomPDF\PDF::loadView() should not be called statically

How to fix this shit error?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 27
  • Comments: 28 (1 by maintainers)

Most upvoted comments

This happens because you are namespacing the wrong PDF class. You are namespacing Barryvdh\DomPDF\PDF and try to use this class as “Facade” which is wrong.

To solve your problem

Set namespace to the facade:

use Barryvdh\DomPDF\Facade as PDF;

Put this on the frontpage somewhere, please.

Thanks, it also worked for me too

This happens because you are namespacing the wrong PDF class. You are namespacing Barryvdh\DomPDF\PDF and try to use this class as “Facade” which is wrong.

To solve your problem

Set namespace to the facade:

use Barryvdh\DomPDF\Facade as PDF;

Thanks.It’s worked for me.

not working for me error : Class "Barryvdh\DomPDF\Facade" not found

Use PDF; This also works.

no eror but no download anything file, can help?

I tried the above solutions. It didn’t work for me. Please help.

Maximum execution time of 60 seconds exceeded, why it comes?

use Barryvdh\DomPDF\Facade as PDF;

Thanks

Thank you. It’s worked for me

use Barryvdh\DomPDF\Facade as PDF;

Yes, this works for me. For some reason my IDE don’t recognize Facade as sugestion when I typed the class xDDD.