A certificate only matters if people trust it. When a learner attaches a PDF to a job application, a hiring manager should be able to confirm it is real in seconds. Laravel gives you the tools to build that trust yourself, without handing control to a third-party platform. You can own the branding, the data, and the verification chain end to end.
The goal is simple: generate a professional PDF that looks sharp when printed, contains a scannable QR code for instant verification, and stores a unique record that cannot be guessed or forged. Here is how to put it together.
Start with the Database Layer
Do not use auto-incrementing IDs for certificates. An ID like 8473 is easy to guess. Someone could cycle through numbers on your verification page and scrape every credential you have ever issued. Instead, generate a UUID when you create the certificate record.
In your migration, store the UUID as a string. When a user finishes a course, fire an event that creates a Certificate model linked to the user and the course. Keep the verification endpoint completely separate from any authenticated dashboard. A public route like /verify/{uuid} should look up the record and display the recipient name, course title, and completion date. If the UUID does not exist, return a 404. No extra login required.
This single design choice protects privacy and prevents enumeration attacks.
Designing the Blade Template
Your certificate design lives in a standard Blade view, but you must treat it differently from a normal web page. PDF rendering engines do not behave like browsers. External stylesheets are unreliable because the PDF converter may not fetch them in the same context. Use inline CSS exclusively.
Think in physical dimensions. If you want a landscape certificate, set the container width and height directly:
<div style="width: 11in; height: 8.5in; position: relative; padding: 40px; font-family: Georgia, serif;">
Position signatures, seals, and borders with absolute positioning inside that container. Web-safe fonts are your safest bet, though some PDF engines allow font embedding if you are careful. Avoid heavy reliance on CSS Grid or advanced Flexbox unless you know your rendering engine supports it. For broad compatibility, old-fashioned table layouts still solve alignment problems that modern CSS cannot guarantee inside a PDF engine.
Keep the markup clean. The simpler the HTML, the less likely the converter is to surprise you with a broken layout.
Adding the QR Code
Install the Simple QRCode package. You need a QR code that points directly to your verification page. In your Blade template, render it like this:
<img src="{!! QrCode::size(150)->generate(route('certificates.verify', $certificate->uuid)) !!}" style="position: absolute; bottom: 40px; right: 40px;">
When an employer scans that code with a phone, they land on your Laravel app and see the live record. That physical-to-digital bridge is what makes the certificate verifiable. A beautiful PDF alone proves nothing. The QR code makes the trust instant and visual.
Choosing a PDF Engine
Laravel developers usually pick one of three paths. Each has genuine trade-offs.
DomPDF runs entirely in PHP. Install it via Composer, pass your Blade-rendered HTML into it, and save the output. It requires no extra server software, which makes it attractive if you are on shared hosting. The downside is CSS support. Modern layout tools like Flexbox and Grid are either partially supported or broken. Custom webfonts can be finicky, and complex backgrounds often render incorrectly. If your certificate design is conservative, DomPDF works. If you need precision, it will frustrate you.
Browsershot takes a different approach. It uses Puppeteer to drive a headless Chrome instance, render your HTML exactly as the browser sees it, and export a PDF. Because it is real Chrome, your Tailwind styles, custom fonts, and responsive layouts all translate perfectly. The catch is server setup. You need Node.js, Puppeteer, and Chrome installed. On some platforms, you must disable the Chrome sandbox or manage memory carefully to prevent stalled processes. If you control your server and need pixel-perfect design replication, Browsershot is hard to beat.
HTML to PDF API üçüncü yoldur. Render edilmiş Blade HTML'inizi bir dize (string) olarak toplarsınız, harici bir servise POST edersiniz ve karşılığında bir PDF alırsınız. Pratik faydası, sunucu tarafında hiçbir bağımlılığın olmamasıdır. Chrome kurmanıza gerek kalmaz. PHP yazı tipi tuhaflıklarıyla uğraşmazsınız. Karşılığında düzgün biçimlendirilmiş bir vektör PDF alırsınız. Bu servislerin çoğu belge başına ücret alır, ancak birçok uygulama için operasyonel basitlik bu maliyete değer. Sistem yöneticisi işleriyle uğraşmadan yüksek kaliteli çıktı istiyorsanız, bu genellikle canlıya çıkmanın en hızlı yoludur.
Tüm İş Akışı
Motorunuzu seçtikten sonra süreç oldukça basittir. Bir kurs tamamlama olayı, aşağıdaki işlemleri yapan bir dinleyiciyi (listener) tetiklemelidir:
- Bir UUID oluşturun ve
Certificatekaydını oluşturun. view('certificates.pdf', compact('certificate'))->render()kullanarak Blade görünümünü bir HTML dizesine dönüştürün.- Bu HTML dizesini seçtiğiniz PDF servisine veya paketine iletin.
- Oluşan dosyayı
certificates/2024/06/uuid.pdfgibi mantıksal bir yolun arkasındakistorage/app/certificates/dizinine kaydedin. - Dosyayı bir bildirime ekleyin ve otomatik olarak öğrenciye e-posta ile gönderin.
Laravel'in bildirim sistemi e-postayı temiz bir şekilde halleder. Render işlemi bir saniyeden uzun sürüyorsa oluşturma işini kuyruğa (queue) alın. Bir öğrencinin sayfa yüklenirken bir PDF'i beklemesini istemezsiniz.
Kullanıcı dosyayı indirdiğinde, herhangi bir görüntüleyicide açılabilen standart bir PDF alır. Yazdırdıklarında, vektör metin netliğini korur. Bir işveren QR kodu tarattığında, Laravel uygulamanız UUID'yi veritabanına karşı doğrular ve bilgileri görüntüler.
Vektör Çıktı Neden Tartışmaya Kapalıdır
Bazı PDF oluşturma yöntemleri rasterize edilmiş (piksel tabanlı) çıktı üretir. Bu, her metin parçasının bir görüntü haline geldiği anlamına gelir. Yakınlaştırdığınızda harfler bulanıklaşır. Dosya boyutları aşırı büyür. Ekran okuyucular ve arama motorları metni ayıklayamaz.
Seçtiğiniz yöntemin gerçek bir vektör PDF ürettiğini her zaman doğrulayın. Metin seçilebilir kalmalıdır. Çizgiler %400 yakınlaştırmada bile keskin kalmalıdır. Öğrencileriniz, PDF olarak kaydedilmiş bir ekran görüntüsü değil, resmi hissettiren bir belgeyi hak ediyor.
Vektör çıktı ayrıca depolama maliyetlerinizi de düşük tutar. Bir sayfalık vektör metin elli kilobayt olabilir. Aynı sayfanın yüksek çözünürlüklü bir görüntü hali iki megabaytı aşabilir. Ölçek büyüdüğünde bu fark önem kazanır.
Kullanabileceğiniz Bir Çıkarım
Bunu kendi bünyenizde oluşturmak sadece bir SaaS sertifika platformuna para tasarrufu yapmakla ilgili değildir. Bu bir güvenilirlik meselesidir. Bir öğrenci bir belgeyi yazdırıp bir masanın üzerinden birine uzatabildiğinde ve bir yabancı bunu telefonla anında doğrulayabildiğinde, onlara kalıcı bir şey vermiş olursunuz. Tasarımı siz kontrol edersiniz. Veriyi siz kontrol edersiniz. Güven, bir satıcının alt alan adına değil, sizin markanıza aittir.
Kendi Laravel uygulamalarınızda sertifika oluşturma ve doğrulama işlemlerini nasıl yönetiyorsunuz? Yorumlarda sizin için nelerin işe yaradığını duymak isterim.
