This package is abandoned and no longer maintained. The author suggests using the Sylius/InvoicingPlugin package instead.

A plugin to generate invoices in Sylius

This package is not auto-updated.

Last update: 2022-02-01 13:10:19 UTC


A Plugin for Sylius to generate invoices


$ composer require behappy/invoice-plugin


This plugin use Knp Snappy Bundle. Please refer to it's documentation for wkhtmltopdf installation (

Enable the plugin

Enable those plugins in AppKernel

// in app/AppKernel.php
public function registerBundles() {
	$bundles = array(
		// ...
        new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
        new \BeHappy\SyliusCompanyDataPlugin\BeHappySyliusCompanyDataPlugin(),
        new \BeHappy\SyliusInvoicePlugin\BeHappySyliusInvoicePlugin(),
    // ...
#in app/config/config.yml
    - { resource: "@BeHappySyliusCompanyDataPlugin/Resources/config/config.yml" }
    - { resource: "@BeHappySyliusInvoicePlugin/Resources/config/config.yml" }
# in routing.yml
    resource: '@BeHappySyliusCompanyDataPlugin/Resources/config/routing.yml'

    resource: '@BeHappySyliusInvoicePlugin/Resources/config/routes/admin.yml'
    prefix: /admin
    resource: '@BeHappySyliusInvoicePlugin/Resources/config/routes/shop.yml'
    prefix: /{_locale}/account
        _locale: ^[a-z]{2}(?:_[A-Z]{2})?$

Generate database

Simply launch

php bin/console doctrine:schema:update --dump-sql --force

You might have tables referring to BeHappySyliusCompanyDataPlugin if you did not enabled it before requiring this plugin

Optional : generate invoices

In order to have invoices for previously placed orders, you can run this command :

php bin/console behappy:invoices:generate

This command will generate invoices for all orders in state FULFILLED with no invoices attached

That's it !

From now on, each and every time an order is fulfilled, the event listener will create a new invoice and copy (if needed) company data information into a separate table to make them static.

A new block is also displayed in admin under the shipment section of orders that have an invoice linked.

In the account section for your customers, a link is also displayed for every invoice linked to their orders.


Invoice number

By default, invoices will be generated with a 12 digits number filled with 0 (str_pad(12, '0', STR_PAD_LEFT))

You can redefine this length definition by overriding this :

# in app/config.yml
    behappy_invoice_plugin.invoice_number.length: 14

Now every invoice will be 14 digits long.

In a near future, this plugin will use a number generator that you'll be free to override according to your needs.


During the invoice creation, 2 events are fired with the order as argument.


You can subscribe to those events and do whatever you need


In order to override the pdf template file, you simply have to create the following file : app/Resources/BeHappySyliusInvoicePlugin/views/Invoice/pdf.html.twig


This plugin is partially inspired by BitBagCommerce/SyliusInvoicingPlugin (

Feel free to contribute

You can also ask your questions at the mail address in the composer.json mentioning this package.


You can also check our other packages (including Sylius plugins) at