mkebza/wk-pdf-bundle
A Laravel/PHP bundle that integrates wkhtmltopdf for generating PDFs from HTML views, giving you a simple wrapper to render templates, configure binary paths and options, and stream or save documents from your application.
Architecture fit — poor as-is. The package is a Symfony bundle (WkPdfBundle), not a Laravel package. Its integration point is Symfony's DI container and bundle registration (Kernel::registerBundles, services.yaml, Configuration tree). Laravel has no equivalent bundle lifecycle, so the package cannot be composer required and used; it would have to be forked or re-wrapped. The underlying capability — shelling out to the wkhtmltopdf binary to convert HTML to PDF — is stack-agnostic, so the functionality is portable even though the package is not. Treat this as a reference implementation, not a dependency.
Integration feasibility — moderate, with adaptation work. The wrapper is thin: binary path config, an invocation service, and presumably an options/command builder. That is likely a few hundred lines and easy to reimplement behind a Laravel service provider or a small internal abstraction (PdfRenderer contract with a WkhtmltopdfRenderer driver). The real cost is not the wrapper but the runtime: the wkhtmltopdf binary must exist on every host/container with the right Qt/WebKit shared libraries and fonts, and must be reachable from PHP with correct permissions.
Technical risk — high, and mostly upstream of this repo.
wkhtmltopdf is built on Qt WebKit, which has been effectively abandoned; the project has had minimal maintenance for years. Modern CSS (flexbox/grid gaps), web fonts, and JS-heavy templates render inconsistently or not at all. Choosing this engine is a multi-year architectural commitment to a legacy renderer.Key questions for the team:
Stack fit — mismatch to resolve first. In a Laravel codebase, the pragmatic path is a build, not buy decision: lift the wrapper's command-building logic into an internal package (app/Support/Pdf or a private Composer package) exposing a framework-agnostic interface, bound in a PdfServiceProvider. This decouples the app from both the Symfony bundle and the specific binary, so the engine can be swapped later.
Migration path — three viable options, in order of preference:
wkhtmltopdf version explicitly, and wrap the call in a queue job. Accept the legacy engine only where output parity is required.Compatibility. Requires PHP version alignment with the bundle's Symfony constraints (likely Symfony 4/5-era, so PHP 7.4–8.1 territory) — verify before assuming it runs on PHP 8.3. Binary/OS compatibility is the sharper edge: Debian/Ubuntu base images need wkhtmltopdf plus libxrender, libxext, libfontconfig, and CJK/emoji fonts if documents include them.
Sequencing:
Maintenance — this becomes our problem. With zero dependents and no maintainer activity, assume no upstream fixes. Budget ongoing ownership: base-image pinning, binary upgrades (which are rare and risky), font package management, and template compatibility testing whenever CSS changes land.
Support. No vendor, no community forum, no CVE feed. Internal runbook and on-call knowledge must be written by us. If the engine is retired upstream mid-cycle, we own the migration.
Scaling. Rendering is CPU- and memory-bound and bursty. Run it on a dedicated queue with a hard concurrency cap separate from general workers, so a large batch of invoices cannot starve user-facing jobs. Expect ~1–3s CPU per page; memory spikes on long documents. Containers need a memory limit above observed peak plus headroom, and a job timeout enforced at both the PHP and process level.
Failure modes to instrument:
/tmp.Ramp-up. Low for invoking the wrapper; moderate-to-high for operating the binary reliably. Allocate a half-day of a senior engineer's time for the spike and a documented runbook (image requirements, fonts, queue config, error taxonomy). Because the package provides no documentation signal and no community, plan for self-authored docs from day one.
TPM recommendation: Do not adopt this package as a dependency. Use it only as a reference for the invocation pattern, and make an explicit engine decision — with the wkhtmltopdf choice justified by a concrete parity constraint, not by convenience.
How can I help you explore Laravel packages today?