PHPackages                             daniel-jorg-schuppelius/php-erechnung-toolkit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. daniel-jorg-schuppelius/php-erechnung-toolkit

ActiveLibrary[Payment Processing](/categories/payments)

daniel-jorg-schuppelius/php-erechnung-toolkit
=============================================

PHP library for creating, parsing and validating electronic invoices (XRechnung, ZUGFeRD/Factur-X) according to EN 16931.

v0.4.4(6d ago)0284AGPL-3.0-or-laterXSLTPHP &gt;=8.1 &lt;8.6CI passing

Since Jan 22Pushed 6d agoCompare

[ Source](https://github.com/Daniel-Jorg-Schuppelius/php-erechnung-toolkit)[ Packagist](https://packagist.org/packages/daniel-jorg-schuppelius/php-erechnung-toolkit)[ RSS](/packages/daniel-jorg-schuppelius-php-erechnung-toolkit/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (11)Versions (24)Used By (0)

PHP E-Rechnung Toolkit
======================

[](#php-e-rechnung-toolkit)

PHP library for creating, parsing and validating electronic invoices (XRechnung, ZUGFeRD/Factur-X) according to EN 16931.

Features
--------

[](#features)

- **XRechnung**: German e-invoicing standard for public sector
- **ZUGFeRD 2.x / Factur-X**: Hybrid PDF/A-3 with embedded XML
- **EN 16931**: European e-invoicing standard
- **XBestellung / Peppol BIS Order**: UBL purchase orders ([docs](docs/XBestellung/README.md))
- **Order-X**: CII purchase orders + hybrid PDF/A-3 (order-side Factur-X)
- **Despatch Advice**: UBL delivery notes (Peppol BIS Despatch Advice)
- **UBL 2.1**: Universal Business Language
- **UN/CEFACT CII D16B**: Cross Industry Invoice

Installation
------------

[](#installation)

```
composer require dschuppelius/php-erechnung-toolkit
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- ext-dom
- ext-libxml
- dschuppelius/php-common-toolkit ^1.0

Quick Start
-----------

[](#quick-start)

### Creating an Invoice

[](#creating-an-invoice)

```
use ERechnungToolkit\Builders\ERechnungDocumentBuilder;
use DateTimeImmutable;

// Create a basic invoice
$invoice = ERechnungDocumentBuilder::create('INV-2026-001')
    ->withIssueDate(new DateTimeImmutable())
    ->withSeller('Muster GmbH', 'DE123456789')
    ->withSellerAddress('Musterstraße 1', '12345', 'Berlin')
    ->withBuyer('Kunde AG')
    ->withBuyerAddress('Kundenweg 2', '54321', 'München')
    ->addLine('Beratungsleistung', 10, 150.00)
    ->build();

// Generate UBL XML (XRechnung)
$ublXml = $invoice->toUblXml();

// Generate CII XML (ZUGFeRD)
$ciiXml = $invoice->toCiiXml();
```

### Creating an XRechnung

[](#creating-an-xrechnung)

```
$leitwegId = '04011000-12345-67';

$xrechnung = ERechnungDocumentBuilder::xrechnung('XR-2026-001', $leitwegId)
    ->withIssueDate(new DateTimeImmutable())
    ->withSeller('Verkäufer GmbH', 'DE123456789')
    ->withSellerAddress('Verkäuferstraße 1', '10115', 'Berlin')
    ->withSellerEndpoint('seller@example.com', 'EM')
    ->withBuyer('Öffentliche Verwaltung')
    ->withBuyerAddress('Amtsweg 1', '80333', 'München')
    ->withBuyerLeitwegId($leitwegId)
    ->addLine('Dienstleistung', 1, 1000.00)
    ->build();
```

### Parsing an Invoice

[](#parsing-an-invoice)

```
use ERechnungToolkit\Parsers\ERechnungParser;

$parser = new ERechnungParser();

// Parse from XML string
$document = $parser->parse($xmlContent);

// Parse from file
$document = $parser->parseFile('/path/to/invoice.xml');

// Access invoice data
echo $document->getId();
echo $document->getSeller()->getName();
foreach ($document->getLines() as $line) {
    echo $line->getItemName() . ': ' . $line->getNetAmount();
}
```

Supported Profiles
------------------

[](#supported-profiles)

ProfileDescriptionMINIMUMZUGFeRD 2.x MINIMUMBASIC\_WLZUGFeRD 2.x BASIC WLBASICZUGFeRD 2.x BASICEN16931EN 16931 (COMFORT)EXTENDEDZUGFeRD 2.x EXTENDEDXRECHNUNGXRechnung 3.0XRECHNUNG\_EXTENSIONXRechnung 3.0 Extension### Order Profiles (XBestellung / Peppol BIS Order)

[](#order-profiles-xbestellung--peppol-bis-order)

ProfileDescriptionPEPPOL\_ORDER\_ONLYPeppol BIS Order only 3 (international)XBESTELLUNGXBestellung v1.0 (German CIUS)Creating an Order (XBestellung)
-------------------------------

[](#creating-an-order-xbestellung)

```
use ERechnungToolkit\Builders\OrderBuilder;
use ERechnungToolkit\Enums\UnitCode;

$order = OrderBuilder::xbestellung('ORD-2026-001')
    ->withBuyer('Stadt Musterstadt')                       // ordering party (sender)
    ->withBuyerAddress('Rathausplatz 1', '12345', 'Musterstadt')
    ->withBuyerEndpoint('04011000-12345-67', '0204')       // Leitweg-ID
    ->withSeller('Lieferant GmbH', 'DE123456789')          // supplier (recipient)
    ->withSellerAddress('Lieferweg 2', '54321', 'Lieferstadt')
    ->withSellerEndpoint('DE123456789', '9930')
    ->addLine('Bürostuhl', 5, 120.00, UnitCode::PIECE, 'ART-4711')
    ->build();

$xml = $order->toUblXml();

// Parsing back
use ERechnungToolkit\Parsers\OrderParser;
$parsed = (new OrderParser)->parse($xml);
```

> The bundled KoSIT validator is scenario-driven and can validate orders once the official XBestellung validation artifacts are added to `data/kosit/scenarios.xml`. See [docs/XBestellung](docs/XBestellung/README.md) for details.

ZUGFeRD/Factur-X PDF Generation
-------------------------------

[](#zugferdfactur-x-pdf-generation)

Generate PDF/A-3 invoices with embedded XML for automated processing. Requires `dschuppelius/php-pdf-toolkit`:

```
composer require daniel-jorg-schuppelius/php-pdf-toolkit
```

```
use ERechnungToolkit\Builders\ERechnungDocumentBuilder;
use ERechnungToolkit\Generators\ZugferdPdfGenerator;

// Create invoice
$invoice = ERechnungDocumentBuilder::zugferd('ZF-2026-001')
    ->withIssueDate(new DateTimeImmutable())
    ->withSeller('Verkäufer GmbH', 'DE123456789')
    ->withSellerAddress('Musterstraße 1', '12345', 'Berlin')
    ->withSellerBankAccount('DE89370400440532013000', 'COBADEFFXXX')
    ->withBuyer('Käufer AG')
    ->withBuyerAddress('Kundenweg 2', '54321', 'München')
    ->addLine('Beratung', 10, 150.00)
    ->build();

// Generate ZUGFeRD PDF with embedded XML
$pdfGenerator = new ZugferdPdfGenerator();
$pdfGenerator->generateToFile($invoice, '/path/to/invoice.pdf');

// Or get PDF as bytes
$pdfBytes = $pdfGenerator->generate($invoice);

// With custom HTML template
$customHtml = '...';
$pdfBytes = $pdfGenerator->generate($invoice, $customHtml);
```

The generated PDF:

- Is PDF/A-3 compliant for long-term archiving
- Contains the embedded XML invoice (CII format)
- Can be processed automatically by accounting software
- Is visually readable as a normal PDF invoice

Validation
----------

[](#validation)

Two layers:

**XSD schema (pure PHP, no Java)** — `UblSchemaValidator` validates UBL documents (Invoice, CreditNote, Order, DespatchAdvice) against the bundled official OASIS UBL 2.1 schemas via libxml. Catches structure / data type / element-order errors.

```
use ERechnungToolkit\Validators\UblSchemaValidator;

$errors = (new UblSchemaValidator)->validate($document->toUblXml()); // [] = valid
```

**Business rules (EN16931 / XRechnung)** — validate UBL/CII against XML Schema, the EN16931 Schematron rules and the XRechnung CIUS using the official [KoSIT validator](https://github.com/itplr-kosit/validator). Both the validator jar (`tools/kosit/validator.jar`) and its configuration (scenarios + schemas, `data/kosit/`) ship with this package, so validation works out of the box.

Because the Schematron rules are distributed as XSLT 2.0 (not executable by PHP's XSLT 1.0 engine), the validator runs as an external Java process.

### Validation Requirements

[](#validation-requirements)

- A Java runtime (`java` on `PATH`) — availability is checked through the Common-Toolkit executable configuration; the call runs via `Java::execute()`
- The KoSIT validator jar — configured as a `javaExecutables` entry in `config/erechnung_executables.json` (default `tools/kosit/validator.jar`). Point `path` at your own jar there, or override per call with an explicit path or the `KOSIT_VALIDATOR_JAR` env var

```
use ERechnungToolkit\Validators\KositValidator;

$validator = new KositValidator(); // uses the bundled jar + Java from PATH

if ($validator->isAvailable()) {
    $result = $validator->validate($ublXml);          // or ->validateFile('/path/to/invoice.xml')

    if ($result->isValid()) {
        echo 'Konform: ' . $result->getScenarioName();
    } else {
        foreach ($result->getErrors() as $error) {
            echo $error->getCode() . ': ' . $error->getText() . PHP_EOL;
        }
    }
}
```

`ValidationResult` exposes the conformance verdict (`isValid()`), the accept/reject recommendation (`isAccepted()`), all rule messages by severity (`getErrors()`, `getWarnings()`, `getMessages()`) and the raw KoSIT report (`getRawReport()`).

License
-------

[](#license)

AGPL-3.0-or-later

Author
------

[](#author)

Daniel Jörg Schuppelius - [schuppelius.org](https://schuppelius.org)

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance99

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Recently: every ~0 days

Total

22

Last Release

6d ago

PHP version history (2 changes)v0.1PHP &gt;=8.2 &lt;8.5

v0.1.11.1PHP &gt;=8.1 &lt;8.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d648df75b8ca254b14377de6aa7c37daff5bc21e9e8742ef7687c7091c7bc94?d=identicon)[l0gtr0n](/maintainers/l0gtr0n)

---

Top Contributors

[![DSchuppelius](https://avatars.githubusercontent.com/u/19145058?v=4)](https://github.com/DSchuppelius "DSchuppelius (2 commits)")

---

Tags

invoiceZUGFeRDfactur-xxrechnungublpeppolorderciiEN16931order-xeinvoicinge-rechnungxbestellungpeppol-bis-order

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/daniel-jorg-schuppelius-php-erechnung-toolkit/health.svg)

```
[![Health](https://phpackages.com/badges/daniel-jorg-schuppelius-php-erechnung-toolkit/health.svg)](https://phpackages.com/packages/daniel-jorg-schuppelius-php-erechnung-toolkit)
```

###  Alternatives

[horstoeko/zugferd

A library for creating and reading european electronic invoices

4295.8M30](/packages/horstoeko-zugferd)[horstoeko/zugferdublbridge

Convert Factur-X/ZUGFeRD (CII-Syntax) to PEPPOL (UBL-Syntax) and visa versa

16175.4k9](/packages/horstoeko-zugferdublbridge)[easybill/e-invoicing

A package to read and create EN16931 e-invoices or CIUS like: XRechnung, ZUGFeRD etc.

14158.3k](/packages/easybill-e-invoicing)[josemmo/einvoicing

Library for reading and creating European-compliant electronic invoices (EN 16931)

177358.5k3](/packages/josemmo-einvoicing)[atgp/factur-x

PHP library to manage your Factur-X / ZUGFeRD 2.0 PDF invoices files

153915.3k4](/packages/atgp-factur-x)[num-num/ubl-invoice

A modern object-oriented PHP library to create and read valid UBL and EN 16931/Peppol BIS 3.0 files

136923.4k](/packages/num-num-ubl-invoice)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
