knplabs/knp-snappy
PHP wrapper for wkhtmltopdf/wkhtmltoimage to generate PDFs and images (thumbnails, snapshots) from URLs or HTML. Simple API, configurable binaries and options, with integrations available for Symfony and Laravel.
Adopt if:
--enable-local-file-access to trusted environments.wkhtmltopdf (e.g., Docker containers, SELinux).wkhtmltopdf options.Look elsewhere if:
wkhtmltopdf requires manual binary installation (OS-specific paths, permissions).--enable-local-file-access risk may outweigh benefits.For Executives: *"This package lets us generate PDFs/thumbnails from web content or HTML in-house, cutting costs and reducing vendor lock-in. For example, we can:
For Engineers: *"Pros:
wkhtmltopdf (no Node.js/Python dependencies).wkhtmltopdf options (e.g., headers, TOC, JavaScript toggles).barryvdh/laravel-snappy) integrate seamlessly with queues, caching, and storage.wkhtmltopdf vulnerabilities.Cons:
wkhtmltopdf (0.12.x) on servers (Docker simplifies this).--enable-local-file-access (use sandboxing).Quick Start:
composer require knplabs/knp-snappy
Then generate a PDF in 3 lines:
$snappy = new Pdf('/usr/bin/wkhtmltopdf');
header('Content-Type: application/pdf');
echo $snappy->getOutput('https://example.com');
Use case: Add this to your InvoiceController to let users download PDFs of their orders."*
How can I help you explore Laravel packages today?