AlthafBudiman's avatar

laravel dompdf server error 500 in production vercel

im trying to use download pdf feature with laravel dompdf and in local it works just fine, buat when i deploy it on the server there's a server error 500..

use Pdf; $pdf = Pdf::loadView('kwitansi.index', [ 'bookings' => [$booking], 'isMember' => $isMember, 'keterangan' => $keterangan, 'totalPrice' => $booking->price, 'noKwitansi' => $request->no_kwitansi, 'showTax' => $request->showTax ])->setPaper('a5', 'landscape');

    return $pdf->download('kwitansi-' . $request->no_kwitansi . '.pdf');

this is the route: Route::get('/lapangan/booking/kwitansi', [BookingController::class, 'showKwitansi'])->name('booking.kwitansi');

0 likes
4 replies
fardeen7337's avatar

I am not sure but If I face this issue how I will debug it, follow the steps I hope the issue will resolved.

enable debugging from .env

APP_DEBUG=true

and then check the error, if it has already enabled then remove all content from blade file just add one

<h1>Hello this is for testing purpose</h1>

then try and replace

return $pdf->download('kwitansi-' . $request->no_kwitansi . '.pdf');

with

return $pdf->download('test.pdf');
AlthafBudiman's avatar

@fardeen7337 in the local it works just fine, but when in production which i use vercel in this case, laravel show 500 | SERVER ERROR page, but there are no other message..

so i don't think there's any error in my code

MouteeSabouni's avatar

@althafbudiman

A 500 server error when generating PDFs with DomPDF on the server (but not locally) usually indicates a server configuration issue or a missing dependency. Have you tried the following?

  1. Missing PHP Extension: Make sure the php-gd and php-mbstring extensions are installed and enabled on the server, as DomPDF relies on them.

  2. Ensure that the directories Laravel needs for storage (storage/, storage/framework/, and storage/logs/) have the correct write permissions, especially if the PDF is temporarily saved before download.

  3. Memory and Execution Limits: PDF generation can be memory-intensive. Increase the memory_limit and max_execution_time values in the server’s php.ini configuration file.

  4. Ensure your DomPDF version is compatible with your Laravel version. Sometimes upgrading or downgrading DomPDF can resolve such issues.

  5. Server-Specific Differences: Some server environments (e.g., shared hosting) may block certain functions required by DomPDF, such as proc_open. Check if this function or others are disabled.

MUHAMMADUSMAN's avatar

check logs check these folder permissions /storage /bootstrap/cache check library is install there or not

Please or to participate in this conversation.