PHPackages                             easybill/e-invoicing - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. easybill/e-invoicing

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

easybill/e-invoicing
====================

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

0.3.2(1y ago)12122.5k—0.4%2[1 issues](https://github.com/easybill/e-invoicing/issues)MITXSLTPHP ^8.2CI passing

Since Jun 26Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/easybill/e-invoicing)[ Packagist](https://packagist.org/packages/easybill/e-invoicing)[ RSS](/packages/easybill-e-invoicing/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (7)Versions (19)Used By (0)

e-invoicing
===========

[](#e-invoicing)

[![Packagist Version](https://camo.githubusercontent.com/0c6af76a6d1ce232f4c0b86966b5290b403512093dded3ae0e78444c2c5bc207/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6561737962696c6c2f652d696e766f6963696e673f6c696e6b3d68747470732533412532462532467061636b61676973742e6f72672532467061636b616765732532466561737962696c6c253246652d696e766f6963696e67)](https://camo.githubusercontent.com/0c6af76a6d1ce232f4c0b86966b5290b403512093dded3ae0e78444c2c5bc207/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6561737962696c6c2f652d696e766f6963696e673f6c696e6b3d68747470732533412532462532467061636b61676973742e6f72672532467061636b616765732532466561737962696c6c253246652d696e766f6963696e67)![Generic badge](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)

Introduction
------------

[](#introduction)

`e-invoicing` is a library to generate and read data of specifications which comply with the EN16931. It is possible to generate CIUS like XRechnung, Peppol BIS Billing and ZUGFeRD / factur-x.

Usage
-----

[](#usage)

```
composer require easybill/e-invoicing
```

### Example: EN16931 Cross Industry Invoice

[](#example-en16931-cross-industry-invoice)

In this example we generate a normal EN16931 as Cross Industry Invoice.

```
use easybill\eInvoicing\CII\Documents\CrossIndustryInvoice;
use easybill\eInvoicing\CII\Models\DocumentContextParameter;
use easybill\eInvoicing\CII\Models\ExchangedDocument;
use easybill\eInvoicing\CII\Models\ExchangedDocumentContext;
use easybill\eInvoicing\CII\Models\DateTime;
use easybill\eInvoicing\Transformer;

$document = new CrossIndustryInvoice();
$document->exchangedDocument = new ExchangedDocument();
$document->exchangedDocumentContext = new ExchangedDocumentContext();
$document->exchangedDocumentContext->documentContextParameter = new DocumentContextParameter();
$document->exchangedDocumentContext->documentContextParameter->id = 'urn:cen.eu:en16931:2017';
$document->exchangedDocument->id = '471102';
$document->exchangedDocument->issueDateTime = DateTime::create(102, '20200305');
// etc...
$xml = Transformer::create()->transformToXml($document)
```

### Example: EN16931 Universal Business Language Invoice

[](#example-en16931-universal-business-language-invoice)

In this example we generate a CIUS (XRechnung 3.0) as UBL document

```
use easybill\eInvoicing\Transformer;
use easybill\eInvoicing\UBL\Documents\UblInvoice;
use easybill\eInvoicing\Enums\CurrencyCode;
use easybill\eInvoicing\Enums\DocumentType;

$document = new UblInvoice();
$document->customizationId = 'urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0';
$document->profileId = 'urn:fdc:peppol.eu:2017:poacc:billing:01:1.0';
$document->id = '123456XX';
$document->issueDate = '2016-04-04';
$document->invoiceTypeCode = DocumentType::COMMERCIAL_INVOICE;
$document->documentCurrencyCode = CurrencyCode::EUR;
$document->buyerReference = '04011000-12345-03';
// etc...
$xml = Transformer::create()->transformToXml($document)
```

### Example: Reading an unknown XML file

[](#example-reading-an-unknown-xml-file)

There might be the case that you receive some XML which may or may not be supported by this library. `e-invoicing` offers a handy way to just parse that XML and see if is deserializable to UBL or CII.

```
use easybill\eInvoicing\Reader;
use easybill\eInvoicing\CII\Documents\CrossIndustryInvoice;

$xml = file_get_contents($exampleXmlFile);

$readerResult = Reader::create()->read($xml);

// If the format is supported and valid in its structure the following check will be true
$readerResult->isSuccess()

// If the format is not supported or a different error occurred the result will have the state error.
$readerResult->isError()

// If it's valid you may retrieve the deserialized object from the dto.
// Invoking the getDocument method on an error will result in a LogicException
$document = $readerResult->getDocument();

if ($document instanceof CrossIndustryInvoice) {
    // do something with the CrossIndustryInvoice
}
```

You can refer to the [tests](https://github.com/easybill/e-invoicing/tree/main/tests/Integration) in this repository for examples of using this library.

Customization
-------------

[](#customization)

This library offers some degree of customization. You may create a customized Reader, Transformer or Writer. By default, the library does not trim whitespaces around values. This is true for values which do not end as enums. If you want to add that the functionality to trim the values you may refer to this [test](https://github.com/easybill/e-invoicing/tree/main/tests/Integration/SerializerTest).

```
 $transformer = new Transformer(ConfiguredSerializer::createWithHandlers([
    new TrimStringValueHandler(),
    new CountryCodeEnumHandler(),
    new CurrencyCodeEnumHandler(),
    new DocumentTypeEnumHandler(),
    new ReferenceQualifierEnumHandler(),
    new UnitCodeEnumHandler(),
    new MimeTypeEnumHandler(),
    new ElectronicAddressSchemeIdentifierEnumHandler(),
]));
```

This allows to register custom handlers, or even add handlers which the library offers but does not include by default (yet) like the TrimStringValueHandler.

Considerations
--------------

[](#considerations)

### Limitations

[](#limitations)

This library does not offer any way to validate the structured data against the rules of EN16931 or any of the CIUS. Please take a look at the folder [Validators](https://github.com/easybill/e-invoicing/tree/main/tests/Validators) in the tests folder. There you will find ways to validate the documents against the CIUS specification rulesets. ZUGFeRD/factur-x offers XSD-Schema-Files which you may use directly in your PHP code. KOSiT offers a dedicated validator to validate your EN16931 document against the XRechnung CIUS specification.

Issues and contribution
-----------------------

[](#issues-and-contribution)

Feel free to create Pull-Requests or Issue if you have trouble with this library or any related resource.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance70

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.7% 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 ~40 days

Recently: every ~59 days

Total

9

Last Release

370d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32529913a7a141306ef087a3b0ed0bb0b237601ea589fe654790eb8a71c4ebd3?d=identicon)[PATROMO](/maintainers/PATROMO)

![](https://www.gravatar.com/avatar/84b57ba1c61296c77e2890264b5814d45800617e64fbfffd7bc46573bc3859b8?d=identicon)[BolZer](/maintainers/BolZer)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (46 commits)")[![BolZer](https://avatars.githubusercontent.com/u/19969518?v=4)](https://github.com/BolZer "BolZer (29 commits)")[![derrabus](https://avatars.githubusercontent.com/u/1506493?v=4)](https://github.com/derrabus "derrabus (1 commits)")[![noone-silent](https://avatars.githubusercontent.com/u/1089817?v=4)](https://github.com/noone-silent "noone-silent (1 commits)")

---

Tags

ciie-invoicee-invoicingen16931factur-xpeppolpeppol-bisublxrechnungxmlZUGFeRDfactur-xxrechnunginvoicingeinvoiceublpeppolciie-invoicingEN16931

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/easybill-e-invoicing/health.svg)

```
[![Health](https://phpackages.com/badges/easybill-e-invoicing/health.svg)](https://phpackages.com/packages/easybill-e-invoicing)
```

###  Alternatives

[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[horstoeko/zugferd

A library for creating and reading european electronic invoices

4174.3M18](/packages/horstoeko-zugferd)[easybill/zugferd-php

ZUGFeRD PHP SDK (Factur-X, XRechnung) - Convert PHP Objects to XML and back.

99295.7k8](/packages/easybill-zugferd-php)[num-num/ubl-invoice

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

135820.5k](/packages/num-num-ubl-invoice)[josemmo/einvoicing

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

173279.6k2](/packages/josemmo-einvoicing)[horstoeko/zugferdublbridge

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

16135.6k5](/packages/horstoeko-zugferdublbridge)

PHPackages © 2026

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