Non-static method should not be called statically I want to generate PDF file from a view in laravel 5.1. I'm using https://github.com/barryvdh/laravel-dompdf
But, Im getting following error:
Non-static method Barryvdh\DomPDF\PDF::loadView() should not be called statically, assuming $this from incompatible context
$pdf = PDF::loadView('invoices.show_invoice', $data);
return $pdf->download('invoice.pdf');
Looks to me like you are using the class directly. You'll need to use the facade if you want to call the methods statically.
Either:
use Barryvdh\DomPDF\Facade as PDF;
or
You can optionally use the facade for shorter code. Add this to your facades:
'PDF' => 'Barryvdh\DomPDF\Facade',
If you don't want to use the facade you can resolve the PDF instance using.
$pdf = app('dompdf.wrapper');
$pdf->loadView('invoices.show_invoice', $data);
I have the same issue. I can resolve the non-static method error.
If I apply the last option and not use the facade, I get this;
Class dompdf.wrapper does not exist
??
Any ideas? Thanks.
Excellent, @phildawson . As simple as it looks the solution you gave was so usefull to me! Thank you so much!
I'm having the same issue but I already havethe
'PDF' => 'Barryvdh\DomPDF\Facade', line in app.php
as well as the accompanying provider line: Barryvdh\DomPDF\ServiceProvider::class,
Why would this error be happening in that case?
Please sign in or create an account to participate in this conversation.