tfox/mpdf-port-bundle
A Symfony bundle that integrates the mPDF library, providing service configuration and a straightforward way to generate PDFs from HTML in Symfony applications.
Framing note: tfox/mpdf-port-bundle is a Symfony2 bundle, not a Laravel package. It is a thin DI wrapper around the mPDF rendering library. In a Laravel context, "leveraging" this package means extracting its pattern (container-scoped renderer, externalised config, factory seam) and reimplementing it on the maintained upstream mpdf/mpdf — not installing the bundle itself.
tempDir, fontDir, fontdata, default page format/margins) and rendering call sites, exposed through a factory so application code never instantiates mPDF directly. That idiom maps directly onto a Laravel service provider + config file + facade/interface. All Symfony-specific artifacts (MpdfPortBundle class, Extension/Configuration, services.yml) are non-portable dead weight.mpdf/mpdf is 1–3 engineering days (singleton binding, config, PdfRenderer interface, one call site), with the real effort in CSS/font fidelity and memory profiling.TPM summary: No-go on adopting the package; go on the pattern, implemented directly on upstream mPDF behind an abstracted renderer.
services.yml autoloading, no DI extension lifecycle). Vendoring and rewriting it is strictly worse than building clean. It is a good design reference for the config/renderer seam.mpdf/mpdf at current stable; verify PHP 8.2/8.3 support and run the security advisory check before it enters the lockfile.MpdfServiceProvider binding a configured instance or PdfRenderer interface as a singleton, config/pdf.php, and interface injection at call sites.PdfRenderer::render(HtmlDocument): BinaryString. Highest-leverage decision; converts a future engine swap into a config change.tempDir and font cache; CJK/RTL fonts add tens of MB per generated file. Validate against production fonts, not defaults. Any legacy Symfony2 consumer requires a behavioural port with golden-file diff tests against old output.| Phase | Work | Exit criteria |
|---|---|---|
| 0 | Licence review (GPLv2 vs. commercial), engine selection | Signed-off licensing position |
| 1 | Spike: 3 representative production templates via upstream mPDF | Fidelity and memory profile accepted |
| 2 | Service provider, config, PdfRenderer interface, one real call site |
Feature-flagged in staging |
| 3 | Queue job, temp-dir strategy, retry/timeout, metrics | Load test at 2× forecast volume |
| 4 | Golden-file regression suite, template versioning | Pagination stable across patch releases |
mpdf/mpdf releases. Budget a recurring line item for periodic upgrade + golden-file revalidation, since a patch release can silently change pagination on archived documents. Pin the minor version.How can I help you explore Laravel packages today?