Laravel-snappy: Call to undefined method Knp\Snappy\Pdf::loadView()

Created on 3 Jan 2016  路  3Comments  路  Source: barryvdh/laravel-snappy

When I tried to get an pdf from the code below I got "Call to undefined method Knp\Snappy\Pdf::loadView()"

$data = [];
$pdf = PDF::loadView('test_view', $data);
return $pdf->download('test.pdf');

In my config/app.php I set the provider index 'Barryvdh\Snappy\ServiceProvider', and I also set the alias 'PDF' => 'Barryvdh\SnappyFacades\SnappyPdf'

I am working with Laravel 5.1

stale

Most helpful comment

Did you import the class?

use Barryvdh\Snappy\Facades\SnappyPdf as PDF;

All 3 comments

Did you import the class?

use Barryvdh\Snappy\Facades\SnappyPdf as PDF;

Looks like you're IDE probably automatically imported Knp\Snappy\Pdf when you typed PDF::.
To use the facade that you've properly set up, just put $pdf = \PDF::loadView('test_view',$data);
Facades will resolve from \<facadeName>:: to the class listed in config/app.php automatically, removing the need for the line above that Chris suggested.

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/KnpLabs/snappy instead. When having doubts, please try to reproduce the issue with just snappy.
If you believe this is an actual issue with the latest version of laravel-snappy, please reply to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

larsemil picture larsemil  路  5Comments

zhuojiawei picture zhuojiawei  路  5Comments

eriktobben picture eriktobben  路  6Comments

jerearaujo03 picture jerearaujo03  路  5Comments

austenc picture austenc  路  7Comments