Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

randomsheep's avatar

[Laravel-dompdf] Class dompdf.wrapper does not exist

Okay, i have installed laravel-dompdf module and defined in config/app.php arrays: ServiceProvider

Barryvdh\DomPDF\ServiceProvider::class,

Facade (aliases array):

'PDF'       => Barryvdh\DomPDF\Facade::class,

Laravel ver. 5.2

I get an error if i trying to use larave-Dompdf lib.:

ReflectionException in Container.php line 738:
Class dompdf.wrapper does not exist
0 likes
7 replies
randomsheep's avatar

i tried:

Use App

$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->stream();

And returning error:

ReflectionException in Container.php line 738:
Class dompdf.wrapper does not exist

In my composer:

        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "nesbot/carbon": "^1.21",
        "intervention/image": "^2.3",
    "barryvdh/laravel-dompdf": "0.6.*"
Hamelraj's avatar

Try this $pdf = \PDF::loadView('name.php') return $pdf->download('namepdf')

if you need you can pass the data $pdf = \PDF::loadView('your php file', compact('data'))

randomsheep's avatar
randomsheep
OP
Best Answer
Level 1

Okay, i found an problem!!

Problem is my with MainService Provider (maybe wrong syntax a little bit)!

dibby's avatar

what was wrong with you MainService Provider? I have exacly the same error on mine project and can not found solution.

jonbnewman's avatar

I was getting this error when I had everything correct except was missing:

Barryvdh\DomPDF\ServiceProvider::class,

...inside of the 'providers' array in config/app.php.

Posting this so others don't get to the bottom of the page without a solution (like I did) because the last guy with a solution decided to peace-out without telling anyone first (I hate that).

1 like
randomsheep's avatar

I extended a blade in provider, and that syntax was a little bit wrong (my fault). That was the reason, why i get an that error about dompdf.wrapper .

RushVan's avatar

I am having the same issue. I have installed 0.7.0 of this package.

Added this to my config/app.php;

    Barryvdh\DomPDF\ServiceProvider::class,

    'PDF'       => Barryvdh\DomPDF\Facade::class,

Then this in the controller;

use Barryvdh\DomPDF\PDF;

$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');

This returns;

Non-static method Barryvdh\DomPDF\PDF::loadView() should not be called statically, assuming $this from incompatible context

If I change the class in the controller to this;

use Barryvdh\DomPDF\Facade as PDF;

I get this;

Class dompdf.wrapper does not exist

??

None of the suggestion here (https://laracasts.com/discuss/channels/laravel/error-while-using-facade) seem to make a difference. Seems like I am somehow missing something...

Please or to participate in this conversation.