Skip to content

Create XRechnung with PHP and Laravel

The German standard based on EN 16931, mandatory for invoices to federal authorities. With Quittio it is a one-line change.

What is XRechnung?

XRechnung is the German standard for e-invoices based on EN 16931. It is plain XML in CII or UBL syntax, with additional German rules (BR-DE). Invoices to authorities need the Leitweg-ID as buyer reference.

Who is it for?

  • Invoices to German federal and many state authorities
  • Businesses that want plain XML without a PDF
  • Systems that process invoices automatically

How it works with Quittio

InvoiceService.php
use Quittio\Core\Builder\Party;
use Quittio\Laravel\Facades\Quittio;

$result = Quittio::invoice()
    ->number('RE-2026-0042')
    ->deliveryDate('2026-09-30')
    ->buyer(Party::make('Kunde AG')
        ->vatId('DE987654321')
        ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE'))
    ->line('Web development', netPrice: '95.00', quantity: 24)
    ->buyerReference('04011000-12345-03')   // Leitweg-ID of the authority
    ->format('xrechnung-cii')
    ->render();
invoice.php
use Quittio\Core\Builder\InvoiceBuilder;
use Quittio\Core\Builder\Party;
use Quittio\Core\Quittio;
use Quittio\Core\Tax\CountryDefaultVat;
use Quittio\Country\DE\CountryDE;

// once at start-up: country pack and default VAT
$quittio = Quittio::create([], [new CountryDE]);
InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries()));

$invoice = InvoiceBuilder::make()
    ->seller($company)   // seller and bank account in code
    ->number('RE-2026-0042')
    ->deliveryDate('2026-09-30')
    ->buyer(Party::make('Kunde AG')
        ->vatId('DE987654321')
        ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE'))
    ->line('Web development', netPrice: '95.00', quantity: 24)
    ->dueInDays(14)   // no default payment term without config/quittio.php
    ->buyerReference('04011000-12345-03');  // Leitweg-ID of the authority

$result = $quittio->make($invoice)->format('xrechnung-cii')->render();

Without Laravel you only need quittio/core and quittio/country-de. The complete script is in the guide E-invoices with plain PHP, no Laravel needed.

Checked with: KoSIT validator with the official XRechnung configuration

Sample files: RE-2026-0042-xrechnung-cii.xml, RE-2026-0042-xrechnung-ubl.xml, KoSIT validation report

Profiles and variants

  • xrechnung-ciiCII syntax
  • xrechnung-ublUBL syntax
  • ZUGFeRD profile XRECHNUNGXRechnung embedded in a PDF
  • xrechnung-extensionProfile with sub lines and third party payments (UBL only) and XML attachments
  • xrechnung-cvdProfile for vehicles under the Clean Vehicles Directive

Version 3.0, BR-DE rules from the German country pack. You choose extension and CVD explicitly with ->profile(…); Quittio checks their rules (BR-DEX, BR-DE-CVD) in PHP already, as the official validator configuration does.

Questions about XRechnung

What is a Leitweg-ID?

The routing address of the authority. It goes into the XRechnung as buyer reference (BT-10). If it is missing, Quittio reports rule BR-DE-15.

CII or UBL?

Both are equivalent. Use whatever your recipient or their portal prefers; with Quittio it is just a different format name.

Do I need a PDF as well?

No, the XRechnung is the invoice. An additional visual PDF is possible but should not be mistaken for a second invoice.

When do I need the XRechnung extension?

When your recipient expects data that XRechnung 3.0 does not allow: sub lines, third party payments or XML files as attachments. Sub lines and third party payments exist in UBL only. Quittio never switches to the extension by itself.

What is XRechnung CVD?

XRechnung 3.0 for road vehicles that a public buyer procures under the Clean Vehicles Directive. The invoice names the contract (BT-12) and the tender or lot (BT-17); every vehicle line carries the vehicle category (M1 to N3) and whether the vehicle is clean, zero-emission or neither. Quittio checks this with the BR-DE-CVD rules.

How does Quittio check a Leitweg-ID?

The German country pack checks the two check digits at the end according to ISO 7064 (Mod 97-10). Only a Leitweg-ID with valid check digits as buyer reference (BT-10) selects XRechnung automatically. An ID with a typo is reported as DE-LEITWEG-ID-SUSPECT; then correct it or choose the format explicitly.

Does this work without Laravel?

Yes. quittio/core and quittio/country-de run in any project with PHP 8.3, with Symfony, another framework or none. The page E-invoices with PHP gives an overview.

When which invoice becomes mandatory is explained in our guide to the German e-invoicing mandate.