Symfony Workflow
The Invoicing Plugin reacts to Sylius/Symfony workflow transitions to create invoices automatically. Typical flow: a payment/order transition fires → the plugin listener emits an internal event → an invoice is generated and linked to the order.
How it works (at a glance)
Workflow transition happens (e.g.,
workflow.sylius_payment.completed.complete
).The plugin’s listener catches the event and produces
order_payment_paid
.The invoice generator creates an immutable PDF and attaches it to the order.
Built-in listener (from the plugin)
XML service definition
<service id="sylius_invoicing_plugin.event_listener.workflow.payment.produce_order_payment_paid"
class="Sylius\InvoicingPlugin\EventListener\Workflow\Payment\ProduceOrderPaymentPaidListener">
<argument type="service" id="sylius_invoicing_plugin.event_producer.order_payment_paid" />
<tag name="kernel.event_listener"
event="workflow.sylius_payment.completed.complete"
priority="100" />
</service>
This listener reacts when a payment completes and emits order_payment_paid
, which the plugin uses to drive invoice creation.
Discover events & debug
List workflow events registered in your app:
bin/console debug:event-dispatcher | grep workflow.sylius_
See your order/payment workflows:
bin/console workflow:dump sylius_order | dot -Tpng -o order.png bin/console workflow:dump sylius_payment | dot -Tpng -o payment.png
Verify your listener is loaded:
bin/console debug:container App\Listener\OrderPaidHook
Best practices
Idempotent listeners: make your code safe to run multiple times.
Priority: use a positive priority (e.g.,
100
) if you must run after core transitions settle.Separation of concerns: emit domain events/webhooks from your listener, keep the invoice generation flow simple.
Testing: create an order, force a transition, and check that a PDF is produced and linked.
Last updated
Was this helpful?