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

cverster's avatar

Dompdf doesn't have access to /tmp/log.htm

I implemented the laraveldaily invoice package, but recently I've had issues generating PDFs and I get the following error:

    [2021-07-16 21:46:31] .ERROR: file_put_contents(/tmp/log.htm): failed to open stream:
    Permission denied {"exception":"[object] (ErrorException(code: 0): file_put_contents(/tmp/log.htm): 
    failed to open stream: Permission denied at /path/to/my/laravel/project/vendor/dompdf/dompdf/src/Dompdf.php:880)
[stacktrace]

So the first thing I did was I went into vendor and edited the following line in the Dompdf Options.php file:

     $this->setLogOutputFile('/path/to/my/laravel/directory/storage/logs/log.htm');
    //        $this->setLogOutputFile($this->getTempDir() . "/log.htm");

This seems to work for when I run artisan commands, but Jobs still fail with the same error. So I have two questions:

  1. Is there something that I need to run before my Jobs will start honoring this change?
  2. How can I give Dompdf permissions to /tmp/log.htm?
0 likes
4 replies
Talinon's avatar

You should never modify the vendor folder, as the next time you update using composer, your changes will be overwritten.

The laravel-invoices package uses the barryvdh/laravel-dompdf package, which of course, uses Dompdf. You should be able to set the temp directory within the Dompdf configuration options.

Check this link for a possible solution:

https://github.com/barryvdh/laravel-dompdf/issues/375

cverster's avatar

Hi there @talinon ! Thanks so much for taking the time to reply to this. The weird thing is my project has no dompdf.php file outside the vendor folder. The barryvdh/laravel-dompdf package uses it, but do I need to publish something in order to gain access to the dompdf.php config file?

Snapey's avatar

my guess is that when you run the artisan commands, it is your account that ends up owning the created file

then when the app tries to do this for itself it can't because you own the file

The easiest solution is to remember to delete the tmp file after you have caused it to be created

Talinon's avatar

If you run php artisan vendor:publish you should be able to find a Provider option for Barryvdh\DomPDF\ServiceProvider. Run that, and it should publish the dompdf.php within your config directory

But, Snapey is probably on the right track thinking it's file permission related. If you configure the path to a sub-directory under your app's Storage directory, make sure both your webserver and the account that runs the artisan command both have permission.

Please or to participate in this conversation.