WeasyPrint for Laravel now supports v53
Published 1 August 2021 in Laravel
Some time back, WeasyPrint announced that it would be moving away from the cairo rendering engine, and developing its own engine, called pydyf. This would be released in v53, which has been in a beta for a few months now.
The time has finally arrived, and the Court Bouillon team has release the stable version of v53.
With it comes a new release of WeasyPrint for Laravel: v6, which doesn’t have any paradigm changes, but does contain a few breaking changes and adds first-class support for Laravel Octane.
Most notably, it removes support for output types altogether, as PNG support is no longer included in WeasyPrint. This makes sense to me, as WeasyPrint was always intended to be used as a PDF engine. Additionally, it removes support for specifying image resolution, which was a PNG-specific feature, as well as image-optimization, which is now covered in a new size-optimization flag that covers fonts too!
When installing a fresh copy of the package, you’ll now get version 6.x, which is specifically built for WeasyPrint v53. If you want to use previous versions of WeasyPrint, 5.x will still be supported.
$ composer install rockett/weasyprint # gives you 6.x$ composer install rockett/weasyprint "^5.0" # gives you 5.x
This release adds support for Octane by making use of scoped singletons. In v5, the package uses immutable singletons, which means that a bunch of methods would clone the service as part of the current request lifecycle, so as to not interfere with the configuration of the singleton (which is available during the entire application lifecycle, instead of the request lifecycle). By using a scoped singleton, Laravel will automatically refresh the singleton for every new request that comes into your Octane application.
As part of this release, I’ve also changed the Git branch structure in order to accomodate support for both major versions. Each maintained version now has its own branch (6.x and 5.x), and breaking changes by contributors should go into the main branch.
Release Notes and Upgrade Guide
Something not right?
As always, feel free to open an issue if you encounter any problems.