PHPackages                             youniwemi/digital-invoice - 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. youniwemi/digital-invoice

ActiveLibrary[Payment Processing](/categories/payments)

youniwemi/digital-invoice
=========================

Digital Invoice is an easy wrapper around easybill/zugferd-php, josemmo/einvoicing and atgp/factur-x that will allow you generate Factur-x and UBL (Peppol, Cius...) invoices in a very easy way.

v0.2.9(2mo ago)72.0k↑145.5%3[1 PRs](https://github.com/Youniwemi/digital-invoice/pulls)MITPHPCI passing

Since Nov 8Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/Youniwemi/digital-invoice)[ Packagist](https://packagist.org/packages/youniwemi/digital-invoice)[ GitHub Sponsors](https://github.com/rahal)[ RSS](/packages/youniwemi-digital-invoice/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (14)Versions (24)Used By (0)

Digital Invoice
===============

[](#digital-invoice)

Digital Invoice offers a unified interface for **generating and reading** e-invoices across all major formats. It wraps `easybill/zugferd-php`, `josemmo/einvoicing`, and `atgp/factur-x` into a single, consistent API.

Supported Formats
-----------------

[](#supported-formats)

FormatProfilesGenerateRead**Factur-X / ZUGFeRD 2.x**`MINIMUM`, `BASIC_WL`, `BASIC`, `EN16931`, `EXTENDED`✓✓**ZUGFeRD 1.0**`CONFORT`, `BASIC`, `EXTENDED`✓✓**XRechnung**—✓✓**UBL**`Peppol`, `NLCIUS`, `CIUS-RO`, `CIUS-IT`, `CIUS-ES-FACE`, `CIUS-AT-NAT`, `CIUS-AT-GOV`, `Malaysia`✓✓Installation
------------

[](#installation)

```
composer require youniwemi/digital-invoice
```

Generating an invoice
---------------------

[](#generating-an-invoice)

```
use DigitalInvoice\Invoice;
use DigitalInvoice\CurrencyCode;
use DigitalInvoice\FacturX;

$invoice = new Invoice('INV-2024-001', new DateTime(), null, CurrencyCode::EURO, FacturX::BASIC);

$invoice->setSeller('12345', '0002', 'ACME Corp', 'ACME');
$invoice->setSellerAddress('1 rue de la Paix', '75001', 'Paris', 'FR');
$invoice->setSellerTaxRegistration('FR12312345678', 'VA');

$invoice->setBuyer('', 'Client SARL');
$invoice->setBuyerAddress('2 avenue de la Gare', '69001', 'Lyon', 'FR');

$invoice->addItem('Consulting', 200.0, 20.0, 2);
$invoice->addPaymentMean('58', 'FR7630006000011234567890189', 'ACME Corp');
$invoice->setPaymentTerms(new DateTime('+30 days'), 'Net 30');

// XML only
$xml = $invoice->getXml();

// PDF with embedded XML (requires a blank PDF template)
$pdf = $invoice->getPdf(file_get_contents('template.pdf'));
```

For UBL:

```
use DigitalInvoice\Ubl;

$invoice = new Invoice('INV-2024-001', new DateTime(), null, CurrencyCode::EURO, Ubl::PEPPOL);
// same setter API …
$xml = $invoice->getXml();
```

Reading an invoice
------------------

[](#reading-an-invoice)

`InvoiceReader` auto-detects the format (CII/FacturX, ZUGFeRD 1.0, UBL) and returns a normalised `InvoiceData` object.

```
use DigitalInvoice\InvoiceReader;

// From XML string
$data = InvoiceReader::fromXml($xml);

// From PDF (extracts embedded CII/FacturX XML automatically)
$data = InvoiceReader::read(file_get_contents('invoice.pdf'));
```

### InvoiceData structure

[](#invoicedata-structure)

```
$data->invoiceId;               // string
$data->issueDate;               // ?DateTime
$data->dueDate;                 // ?DateTime
$data->currency;                // string  e.g. 'EUR'
$data->profile;                 // string  URN or format identifier
$data->invoiceType;             // string  e.g. '380'

$data->seller;                  // ?PartyData
$data->buyer;                   // ?PartyData
$data->buyerReference;          // ?string

$data->notes;                   // array  [{content, subjectCode, contentCode}]
$data->items;                   // InvoiceItemData[]
$data->paymentMeans;            // PaymentMeanData[]
$data->paymentTermsDescription; // ?string

// Monetary totals
$data->taxBasisTotal;           // ?float  net amount (excl. VAT)
$data->taxTotal;                // ?float  total VAT amount
$data->grandTotal;              // ?float  total incl. VAT
$data->duePayable;              // ?float

// Tax breakdown — one entry per rate/category
$data->taxBreakdown;            // TaxBreakdownData[]
```

#### TaxBreakdownData

[](#taxbreakdowndata)

```
$tb->rate;             // float   e.g. 20.0
$tb->basisAmount;      // ?float  taxable base for this rate
$tb->calculatedAmount; // ?float  VAT amount for this rate
$tb->categoryCode;     // ?string S, Z, E, AE, K …
$tb->exemptionReason;  // ?string
```

#### PartyData

[](#partydata)

```
$party->name;             // string
$party->tradingName;      // ?string
$party->id;               // ?string  legal/company ID value
$party->idType;           // ?string  ISO 6523 scheme code e.g. '0002'
$party->address;          // ?AddressData  (lineOne, postCode, city, countryCode …)
$party->contact;          // ?ContactData  (name, phone, email)
$party->taxRegistrations; // array  [{id, schemeID}]  e.g. VAT number
$party->identifiers;      // array  [{id, idType}]    additional IDs
```

Rendering an invoice to HTML
----------------------------

[](#rendering-an-invoice-to-html)

`InvoiceRenderer` turns any parsed `InvoiceData` into a self-contained HTML fragment with inlined CSS. It supports custom templates, custom CSS, and three UI languages out of the box.

```
use DigitalInvoice\InvoiceRenderer;

$data = InvoiceReader::fromXml($xml);

// Default (English)
$html = (new InvoiceRenderer())->render($data);

// French labels
$html = (new InvoiceRenderer(lang: 'fr'))->render($data);

// German labels
$html = (new InvoiceRenderer(lang: 'de'))->render($data);

// Custom template and/or CSS
$html = (new InvoiceRenderer('/path/to/template.php', '/path/to/styles.css'))->render($data);
```

The default template (`src/templates/invoice.html.php`) and stylesheet (`src/templates/invoice.css`) can be replaced entirely. The template receives these variables:

VariableTypeDescription`$invoice``InvoiceData`The parsed invoice`$cur``string`Currency code`$labels``array`Translated UI strings`$esc``Closure``fn(?string): string` — HTML-safe output`$fmt``Closure``fn(?float, string): string` — formatted amount`$date``Closure``fn(?\DateTime): string` — formatted date`$schemeLabel``Closure``fn(string): string` — human label for ISO 6523 / tax scheme`$formatLabel``Closure``fn(string): string` — human label for invoice format/profileInteractive viewer
------------------

[](#interactive-viewer)

`viewer.php` provides a browser-based upload-and-preview page: upload any invoice file on the left, see the rendered HTML on the right. No files are stored server-side.

```
php -S localhost:8000
# open http://localhost:8000/viewer.php
```

Key Features
------------

[](#key-features)

- **Read &amp; Generate** — round-trip support for all formats
- **Tax breakdown** — per-rate base amount, VAT amount, and category code from any parser
- **HTML rendering** — self-contained fragment with inlined CSS, i18n (EN/FR/DE), format badge, SIRET/VAT labels
- **Identifier support** — SIRET, SIREN, DUNS, LEI, VAT, and 60+ ISO 6523 codes
- **Multi-currency** — including MYR for Malaysian e-invoices
- **Secure by default** — DOCTYPE guard, LIBXML\_NONET, upload MIME validation, XSS-safe renderer

Development Status
------------------

[](#development-status)

Active development — API may change between minor versions.

Collaboration and contributions are welcome. Open an issue or PR for specific use cases or format requests.

Contributors
------------

[](#contributors)

- @yassiNebeL — UBL format support via josemmo/einvoicing

Credits
-------

[](#credits)

- [easybill/zugferd-php](https://github.com/easybill/zugferd-php) — Factur-X, XRechnung, ZUGFeRD generation and reading
- [josemmo/einvoicing](https://github.com/josemmo/einvoicing) — UBL invoice generation and reading
- [atgp/factur-x](https://github.com/atgp/factur-x) — PDF embedding/extraction for Factur-X
- [Tiime-Software/EN-16931](https://github.com/Tiime-Software/EN-16931) — Structured data types for e-invoicing

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance88

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.6% 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 ~47 days

Recently: every ~71 days

Total

20

Last Release

60d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/434d10de4e57eb930e47e929c07b956e13153ae9738179eecd10151b65e08b59?d=identicon)[rahal](/maintainers/rahal)

---

Top Contributors

[![rahal](https://avatars.githubusercontent.com/u/34531?v=4)](https://github.com/rahal "rahal (31 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (16 commits)")[![yassiNebeL](https://avatars.githubusercontent.com/u/108750248?v=4)](https://github.com/yassiNebeL "yassiNebeL (1 commits)")

---

Tags

e-invoicingfactur-xpeppolublinvoiceZUGFeRDfactur-xdigital invoiceublpeppole-invoicingCius

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/youniwemi-digital-invoice/health.svg)

```
[![Health](https://phpackages.com/badges/youniwemi-digital-invoice/health.svg)](https://phpackages.com/packages/youniwemi-digital-invoice)
```

###  Alternatives

[horstoeko/zugferd

A library for creating and reading european electronic invoices

4295.8M30](/packages/horstoeko-zugferd)[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)[atgp/factur-x

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

153915.3k4](/packages/atgp-factur-x)[josemmo/einvoicing

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

177358.5k3](/packages/josemmo-einvoicing)[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)

PHPackages © 2026

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