Thanh Toàn
Thanh Toàn

Reputation: 145

Laravel- Dompdf Maximum execution time of 60 seconds exceeded

Here is error when i convert pdf, it's not working since i run my laravel project by "php artisan serve --port=1000". But if i run my laravel project with xampp. it's alright. I don't know why?. Give me explaination and repairs . Thank you

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
    Maximum execution time of 60 seconds exceeded

Upvotes: 9

Views: 35185

Answers (9)

Aruni Weerasekara
Aruni Weerasekara

Reputation: 21

Don't use Bootstrap or any external CSS for your printable PHP file. as well as don't use any internal CSS for this.

  • only use inline CSS for your invoice

Upvotes: 0

LordBach97
LordBach97

Reputation: 31

use public_path for your external files for exe href="{{public_path('style.css')}}"

Upvotes: 3

Ashfaq Adib
Ashfaq Adib

Reputation: 220

What I found was referencing to assets via asset() helper in the PDF view was throwing timeout exceeded error, I changed it to public_path() and it started working fine.

Upvotes: 10

Abdul Rehman
Abdul Rehman

Reputation: 192

dompdf does not work on php artisan server

You should go through xampp server. It solved my problem

Upvotes: 2

hassanrazadev
hassanrazadev

Reputation: 664

For me, there were two main issues.

  1. Using images directly: I was using images with storage_path() so, I first convert image to base64 and pass it to the blade view.
  2. Using external CSS: I was using bootstrap as external CSS and as we don't need whole bootstrap CSS, I just copy required CSS from bootstrap and place in internally with <style>..</style>

These steps make the PDF generation process very fast.

Upvotes: 3

Rodrigo Basilio
Rodrigo Basilio

Reputation: 186

The laravel - dompdf does not work well with php artisan serve. You should use XAMPP or another HTTP server you like.

Upvotes: 15

SirVineyard
SirVineyard

Reputation: 11

Possible causes:

linking to external CSS - you're better off writing your css between style tags in the same file as your html

using blade templating syntax e.g. @sections @roles, etc

linking to external images

Complex table structures/layouts

...from personal experience

Upvotes: 1

user558720
user558720

Reputation: 164

I had the same problem and narrowed it down to linking to an image in my blade file. When I embedded the image instead as per this SO answer, it no longer timed out.

Upvotes: 1

AddWeb Solution Pvt Ltd
AddWeb Solution Pvt Ltd

Reputation: 21681

Increase Your time limit in your controller file.Below variable to increase your time limit.

 set_time_limit(300);

Upvotes: 8

Related Questions