pontedilana/php-weasyprint
PHP 8.3+ wrapper around WeasyPrint (v60+) to generate PDFs from URLs or HTML. Snappy-inspired, drop-in style API with strict typing. Set the weasyprint binary, pass CLI options, stream to browser or write files.
GeneratorInterface) allows seamless integration into Laravel’s existing PDF generation workflows (e.g., replacing barryvdh/laravel-snappy).GeneratorInterface contract, enabling zero-code changes for existing Snappy-based workflows (e.g., snappy()->getOutput() → pdf()->getOutput()).--media-type, --stylesheet).https://example.com/invoice) and local HTML strings, broadening use cases (e.g., dynamic PDFs from database-stored HTML).php artisan queue:work).http, https by default).--pdf-tags, --xmp-metadata) required?composer require pontedilana/php-weasyprint.Pdf::make() facade) to replace Snappy.ShouldQueue for async generation.Artisan).KnpLabs/snappy with pontedilana/php-weasyprint in composer.json.SnappyPdf → PhpWeasyPrint\Pdf).getOutput() and generateFromHtml() methods.GeneratePdfJob).database, redis) for scalability.--pdf-version, --timeout).| Step | Task | Dependencies | Risk |
|---|---|---|---|
| 1 | Install WeasyPrint | Python 3.8+ | High (env setup) |
| 2 | Replace Snappy in composer.json |
- | Low |
| 3 | Update service bindings | Laravel DI | Low |
| 4 | Test synchronous generation | WeasyPrint binary | Medium |
| 5 | Implement queue jobs | Laravel Queues | Low |
| 6 | Add error handling | Logging (Monolog) | Low |
| 7 | Optimize timeouts | WeasyPrint CLI options | Medium |
| 8 | Deploy to staging | CI/CD pipeline | High |
--debug flag for troubleshooting).sys_get_temp_dir() for cleanup.PATH or use absolute binary path.--debug flag.setTimeout() or use queues.weasyprint --help for CLI options.php artisan weasyprint:debug (custom command to validate setup).cairo).memory_get_usage().| Failure Scenario | Impact | Mitigation |
|---|---|---|
| WeasyPrint binary missing | All PDFs fail | CI/CD check for binary existence |
| Python/WeasyPrint version mismatch | Rendering errors | Pin versions in Dockerfile |
| Out-of-memory (OOM) |
How can I help you explore Laravel packages today?