[Maintenance][DX] Add support for PDF generation abstraction#426
Open
NoResponseMate wants to merge 1 commit intoSylius:2.2from
Open
[Maintenance][DX] Add support for PDF generation abstraction#426NoResponseMate wants to merge 1 commit intoSylius:2.2from
NoResponseMate wants to merge 1 commit intoSylius:2.2from
Conversation
Wojdylak
approved these changes
Mar 26, 2026
TheMilek
approved these changes
Mar 26, 2026
3c81ad8 to
ce9f439
Compare
TheMilek
approved these changes
Mar 26, 2026
ce9f439 to
bb0876f
Compare
bb0876f to
0bee807
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for
sylius/pdf-generation-bundleas a modern alternative to the legacy PDF generation setup based onKnpSnappyBundlewith a hardcodedwkhtmltopdfbinary.The new integration is opt-in and fully backward compatible — existing setups continue to work without any changes.
Motivation
The current PDF generation in InvoicingPlugin is tightly coupled to
KnpSnappyBundleandwkhtmltopdf. Thesylius/pdf-generation-bundleprovides a proper abstraction layer with support for multiple adapters, context-based configuration, and a unified filesystem management — making it easier to swap PDF engines or customize the generation pipeline.How to use it
To switch from the legacy PDF generation to the new bundle, set the
legacyoption tofalsein your configuration:That's it. The plugin automatically configures a
sylius_invoicingcontext insylius/pdf-generation-bundlewith theknp_snappyadapter andgaufrettestorage, making it a drop-in replacement.For more details on available adapters, storage options, and custom option processors, refer to the
sylius/pdf-generation-bundledocumentation.Deprecations
The following classes, interfaces, and services have been deprecated and will be removed in 3.0:
Sylius\InvoicingPlugin\Generator\TwigToPdfGeneratorInterfaceSylius\PdfGenerationBundle\Core\Renderer\TwigToPdfRendererInterfacefromsylius/pdf-generation-bundleSylius\InvoicingPlugin\Generator\TwigToPdfGeneratorSylius\PdfGenerationBundle\Core\Renderer\TwigToPdfRendererInterfacefromsylius/pdf-generation-bundleSylius\InvoicingPlugin\Generator\PdfOptionsGeneratorInterfacesylius/pdf-generation-bundleSylius\InvoicingPlugin\Generator\PdfOptionsGeneratorsylius/pdf-generation-bundleSylius\InvoicingPlugin\Manager\InvoiceFileManagerInterfaceSylius\PdfGenerationBundle\Core\Filesystem\Manager\PdfFileManagerInterfacefromsylius/pdf-generation-bundleSylius\InvoicingPlugin\Manager\InvoiceFileManagerSylius\PdfGenerationBundle\Core\Filesystem\Manager\PdfFileManagerfromsylius/pdf-generation-bundleThe corresponding services (
sylius_invoicing.generator.twig_to_pdf,sylius_invoicing.generator.pdf_options) are also deprecated.The following services now accept new argument types from the
SyliusPdfGenerationBundle. Passing the old types is deprecated and will be removed in 3.0:Sylius\InvoicingPlugin\Generator\InvoicePdfFileGenerator:Sylius\InvoicingPlugin\Creator\InvoiceCreator:public function __construct( private readonly InvoiceRepositoryInterface $invoiceRepository, private readonly OrderRepositoryInterface $orderRepository, private readonly InvoiceGeneratorInterface $invoiceGenerator, private readonly InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator, - private readonly InvoiceFileManagerInterface $invoiceFileManager, + private readonly InvoiceFileManagerInterface|PdfFileManagerInterface $invoiceFileManager, private readonly bool $hasEnabledPdfFileGenerator = true, )Sylius\InvoicingPlugin\Provider\InvoiceFileProvider— the$invoiceFileManagerand$invoicesDirectoryarguments are also deprecated and will be removed in 3.0:public function __construct( private readonly InvoiceFileNameGeneratorInterface $invoiceFileNameGenerator, - private readonly FilesystemInterface $filesystem, + private readonly FilesystemInterface|PdfFileManagerInterface $filesystem, private readonly InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator, - private readonly InvoiceFileManagerInterface $invoiceFileManager, - private readonly string $invoicesDirectory, + private readonly ?InvoiceFileManagerInterface $invoiceFileManager = null, + private readonly ?string $invoicesDirectory = null, )Issues
Fixes #376