Laravel- Dompdf Maximum execution time of 60 seconds exceeded
Asked Answered
C

9

9

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
Crankpin answered 22/3, 2018 at 5:33 Comment(4)
put set_time_limit(6000); variable in in your controller file.Aggress
How did you put it? i've already done but still not working .Skatole
I got it. I set it set_time_limit(300). That's better. Thank youSkatole
which laravel package you are using from generate the DOMPDF?Aggress
F
14

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

Figment answered 30/7, 2018 at 11:10 Comment(0)
F
10

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.

Franglais answered 5/10, 2021 at 12:25 Comment(2)
This is the best wayPalaeo
But what about GD library which is mandatory for using public_path from laravel? Just for the record, using public_path is using the absolute server URL, not a logic server url. It would be a better solution finding the root cause, I mean, if your server is not handling self-requests as importing images from a larvael blade file, you must fix that instead going straight and use public_path which actually is not recommended!Anabelanabella
A
8

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

 set_time_limit(300);
Aggress answered 22/3, 2018 at 6:5 Comment(5)
yup but it's pretty long to convert.Skatole
It's resolved. But Do you have any ways to convert pdf with the speed is faster than now?.it's really slow. Thank you very muchSkatole
which laravel package you are using from generate the DOMPDF?Aggress
@Thanh Toàn yes, it's the good package. I think a problem with your data limits.Aggress
@Thanh Toàn Thanks for the thank you. Feel free to accept this as answer and upvote if our solution addressed your concern.Aggress
B
3

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.

Beem answered 29/6, 2020 at 6:30 Comment(0)
B
3

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

Ballet answered 13/9, 2022 at 17:17 Comment(1)
In your pdf blade page, replace asset by public_pathBallet
K
2

dompdf does not work on php artisan server

You should go through xampp server. It solved my problem

Kalle answered 5/4, 2021 at 10:8 Comment(0)
D
1

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.

Deontology answered 6/10, 2018 at 16:21 Comment(0)
B
1

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

Brenna answered 4/1, 2019 at 17:15 Comment(1)
Linking to external CSS is actually best practice, as you only need to change a given class in one place, not in all pages.Biparty
A
0

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
Adon answered 25/7, 2024 at 6:28 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.