---
title: "Read ZUGFeRD and XRechnung invoices with PHP · Quittio"
description: "Read incoming e-invoices in PHP: extract the XML from a ZUGFeRD PDF, read XRechnung in CII and UBL, validate it and check the totals. With a code example."
canonical_url: "https://quittio.dev/en/guides/read-e-invoices-with-php"
last_updated: 2026-11-13
locale: en
meta:
  "og:description": "Read incoming e-invoices in PHP: extract the XML from a ZUGFeRD PDF, read XRechnung in CII and UBL, validate it and check the totals. With a code example."
  "og:image": "https://quittio.dev/og/ratgeber-lesen-en.jpg"
  "og:image:alt": "Read incoming e-invoices with PHP: the code that reads a ZUGFeRD PDF or an XRechnung with quittio/core."
  "og:image:height": "630"
  "og:image:type": image/jpeg
  "og:image:width": "1200"
  "og:title": "Read ZUGFeRD and XRechnung invoices with PHP · Quittio"
  "twitter:image": "https://quittio.dev/og/ratgeber-lesen-en.jpg"
  "twitter:image:alt": "Read incoming e-invoices with PHP: the code that reads a ZUGFeRD PDF or an XRechnung with quittio/core."
---

> Index of every page on this site: [llms.txt](https://quittio.dev/llms.txt)

# Read incoming e-invoices with PHP

Since 2025 your suppliers in Germany may send you e-invoices. Here is how to read ZUGFeRD PDFs and XRechnung files in PHP, validate them and take the values into your accounting.

**How-to**13 Nov 2026 · about 8 minutes

**In short**

With `quittio/core`, `read()` reads the content of an XML or PDF file and `readFile()` a local file. Both recognise CII, UBL and ZUGFeRD/Factur-X PDFs, extract the embedded XML from the PDF and return the values in the same data model you use to create invoices. `validateFile()` checks the file on all enabled validation levels. Amounts are never corrected silently: Quittio reports differences as `QUITTIO-DECLARED-TOTALS`.

## What an e-invoice contains

An e-invoice is an XML file according to EN 16931, in CII or UBL syntax. With XRechnung you usually get the XML only. With ZUGFeRD (Factur-X in France) you get a PDF/A-3 with the XML embedded as a file. The XML is what counts, not what the PDF shows. More on the formats in the guide [ZUGFeRD, XRechnung or Peppol](https://quittio.dev/en/guides/zugferd-xrechnung-or-peppol).

| File | Recognised by | Content |
| --- | --- | --- |
| CII XML | root element `CrossIndustryInvoice` | ZUGFeRD 2.x / Factur-X MINIMUM to EXTENDED, XRechnung CII |
| UBL XML | root element `Invoice` or `CreditNote` (UBL 2.1) | EN 16931, XRechnung UBL, Peppol BIS Billing 3.0 |
| PDF | content starts with `%PDF` | ZUGFeRD 2.x / Factur-X, XRechnung in a PDF |

Quittio detects the profile from the specification identifier (BT-24). XRechnung counts once the German country pack is registered.

## Installation

Without Laravel, the core and the German country pack are enough. In Laravel, install `quittio/quittio`, which includes the integration.

$`composer require quittio/core quittio/country-de`

## Reading a file

`read()` always takes the content of the document, never a file name, so you can pass uploads and request bodies directly. `readFile()` reads a local file:

IncomingInvoiceController.php

```
use Quittio\Laravel\Facades\Quittio;

$read = Quittio::read($request->file('invoice')->get());   // content of an uploaded XML or PDF
$read = Quittio::readFile('/path/to/invoice.pdf');          // or a local file

$invoice = $read->data;          // InvoiceData as stated in the document
$invoice->number;                // "RE-2026-0042"
$invoice->seller->name;          // the supplier
$invoice->totals?->amountDue;    // amount due as stated in the document

$read->profile;                  // detected profile, e.g. "en16931" or "xrechnung"
$read->findings;                 // problems found while reading, e.g. QUITTIO-DECLARED-TOTALS
$read->embeddedFilename;         // for PDFs: factur-x.xml, xrechnung.xml …
```

incoming.php

```
use Quittio\Core\Quittio;
use Quittio\Country\DE\CountryDE;

$quittio = Quittio::create([], [new CountryDE]);

$read = $quittio->read(file_get_contents($_FILES['invoice']['tmp_name']));   // content of an uploaded XML or PDF
$read = $quittio->readFile('/path/to/invoice.pdf');                          // or a local file

$invoice = $read->data;          // InvoiceData as stated in the document
$invoice->number;                // "RE-2026-0042"
$invoice->seller->name;          // the supplier
$invoice->totals?->amountDue;    // amount due as stated in the document

$read->profile;                  // detected profile, e.g. "en16931" or "xrechnung"
$read->findings;                 // problems found while reading, e.g. QUITTIO-DECLARED-TOTALS
$read->embeddedFilename;         // for PDFs: factur-x.xml, xrechnung.xml …
```

The result is a `ReadResult`. `data` holds the values as stated in the document, `syntax` is `cii` or `ubl`, `declaredTotals` the stated totals and `xml` the XML that was read, for a PDF the embedded one.

## Validate before booking

Reading does not validate the whole document. Before you book an invoice, check it on the same levels Quittio uses for its own invoices (EN 16931, XRechnung, Peppol, XSD; plus the KoSIT validator and veraPDF if you enabled them):

IncomingInvoiceController.php

```
$report = Quittio::validateFile($content);   // content of an XML or PDF
$report = Quittio::validatePath($path);      // or a local file

if (! $report->isValid()) {
    // reject the invoice, e.g. show $report->errors()
}
```

incoming.php

```
$report = $quittio->validateFile($content);   // content of an XML or PDF
$report = $quittio->validatePath($path);      // or a local file

if (! $report->isValid()) {
    // reject the invoice, e.g. show $report->errors()
}
```

How to set up the official validators is explained in the guide [Validating e-invoices](https://quittio.dev/en/guides/validating-e-invoices-kosit-verapdf).

## Taking the values into accounting

A complete example: accept an upload, validate it, extract the values for accounting.

IncomingInvoiceController.php

```
use Quittio\Laravel\Facades\Quittio;

$content = $request->file('invoice')->get();          // uploaded PDF or XML

$report = Quittio::validateFile($content);
if (! $report->isValid()) {
    return back()->withErrors(array_map(fn ($m) => "[{$m->code}] {$m->message}", $report->errors()));
}

$read = Quittio::read($content);
$invoice = $read->data;

$booking = [
    'supplier' => $invoice->seller->name,
    'supplier_vat_id' => $invoice->seller->vatId,
    'number' => $invoice->number,
    'issue_date' => $invoice->issueDate->toIsoString(),
    'due_date' => $invoice->dueDate?->toIsoString(),
    'amount_due' => (string) $invoice->totals?->amountDue->getAmount(),
    'currency' => $invoice->currency,
    'iban' => $invoice->paymentInstructions?->primaryCreditTransfer()?->accountId,
    'profile' => $read->profile,                           // e.g. "en16931" or "xrechnung"
];
```

incoming.php

```
$content = file_get_contents($_FILES['invoice']['tmp_name']);   // uploaded PDF or XML

$report = $quittio->validateFile($content);
if (! $report->isValid()) {
    return array_map(fn ($m) => "[{$m->code}] {$m->message}", $report->errors());   // e.g. to show them with the form
}

$read = $quittio->read($content);
$invoice = $read->data;

$booking = [
    'supplier' => $invoice->seller->name,
    'supplier_vat_id' => $invoice->seller->vatId,
    'number' => $invoice->number,
    'issue_date' => $invoice->issueDate->toIsoString(),
    'due_date' => $invoice->dueDate?->toIsoString(),
    'amount_due' => (string) $invoice->totals?->amountDue->getAmount(),
    'currency' => $invoice->currency,
    'iban' => $invoice->paymentInstructions?->primaryCreditTransfer()?->accountId,
    'profile' => $read->profile,                           // e.g. "en16931" or "xrechnung"
];
```

For a ZUGFeRD invoice of 24 hours at €95 net, `$booking` is:

booking.json

```
{"supplier":"Muster GmbH","supplier_vat_id":"DE123456789","number":"RE-2026-0042","issue_date":"2026-10-01","due_date":"2026-10-15","amount_due":"2713.20","currency":"EUR","iban":"DE02120300000000202051","profile":"en16931"}
```

## Totals are never corrected silently

Quittio keeps the amounts as stated in the document and recalculates a copy from the lines for comparison. Every difference in the line amounts, the sum of lines, the totals without and with VAT, the VAT total and the amount due is reported as warning `QUITTIO-DECLARED-TOTALS`, for example:

Finding

```
QUITTIO-DECLARED-TOTALS: Amount due (BT-115): declared 2700.00, recalculated 2713.20.
```

`$read->data->totals` still holds the stated amount. Whether you reject such an invoice or ask the supplier is up to you.

## Findings while reading

The reader is tolerant: it reads as much as possible and reports problems as findings instead of failing. Some examples:

| Code | Meaning |
| --- | --- |
| `BR-03` | The issue date (BT-2) is missing or unreadable |
| `BR-05` | The invoice currency (BT-5) is missing or not an ISO 4217 code |
| `QUITTIO-READER-UNKNOWN-PROFILE` | The specification identifier (BT-24) is not known to this installation |
| `QUITTIO-READER-PDF-CANDIDATES` | The PDF embeds several invoice files with different content |
| `QUITTIO-DECLARED-TOTALS` | The stated amounts differ from the recalculation |

The full list is in the documentation under [Reading incoming invoices](https://quittio.dev/en/docs/reading#findings).

## Limits and security

Incoming files come from outside, so Quittio limits what it accepts:

- XML with a DOCTYPE is rejected, so there are no external entities (XXE) and no entity expansion.
- Size limits: XML 10 MB, PDF 25 MB, every decompressed PDF stream 50 MB (configurable).
- Encrypted PDFs cannot be read.
- File names of embedded files are never used as paths.

An exception is thrown only when the document cannot be read at all: an unknown format, ZUGFeRD 1.0 (not EN 16931), a PDF without an embedded invoice, a missing or too large file. All three exception classes implement `QuittioException`.

## On the command line (Laravel)

In Laravel, two Artisan commands show the content of a file and its validation report:

Terminal

```
php artisan quittio:read invoice.pdf          # number, date, profile, parties, lines, totals, findings
php artisan quittio:read invoice.xml --json   # InvoiceData as JSON
php artisan quittio:validate invoice.pdf      # validation report
```

Without Laravel there are no console commands; `read()` and `validateFile()` return the same data.

## Frequently asked questions

### **Can I read ZUGFeRD invoices without Laravel?**

Yes. `read()`, `readFile()` and `validateFile()` are part of `quittio/core` and run in any project with PHP 8.3. The page [E-invoices with PHP](https://quittio.dev/en/php) gives an overview.

### **Do I have to extract the XML from the PDF myself?**

No. Quittio finds the embedded XML of a ZUGFeRD or Factur-X PDF and reads it. `embeddedFilename` shows its file name.

### **Does Quittio correct wrong totals?**

No. The values stay as stated in the document. Quittio reports differences from the recalculation as warning `QUITTIO-DECLARED-TOTALS`.

### **Does Quittio read ZUGFeRD 1.0?**

No. ZUGFeRD 1.0 does not conform to EN 16931 and is rejected with a clear message.

### **Can I safely read uploads from unknown senders?**

Quittio rejects XML with a DOCTYPE, limits sizes and PDF structures and never uses embedded file names as paths. Still validate the invoice before you book it.

**As of: 13 Nov 2026. Not tax or legal advice.**

Sources: [Quittio documentation: Reading incoming invoices](https://quittio.dev/docs/reading) · [Quittio documentation: Examples, Incoming e-invoices](https://quittio.dev/docs/examples#incoming-e-invoices)

## Read next

- [**How-to**

  **Validating e-invoices: KoSIT validator and veraPDF in CI**

  The seven validation levels, setting up the official validators and automating them in GitHub Actions.](https://quittio.dev/en/guides/validating-e-invoices-kosit-verapdf)
- [**How-to**

  **Create e-invoices with plain PHP, no Laravel needed**

  Quittio runs in any PHP 8.3 project: Symfony, Slim, a Shopware plugin or your own framework.](https://quittio.dev/en/guides/e-invoices-with-php-without-laravel)
- [**Formats**

  **ZUGFeRD, XRechnung or Peppol: which format do you need?**

  How the formats differ, who needs which and how Quittio chooses automatically.](https://quittio.dev/en/guides/zugferd-xrechnung-or-peppol)

## Read incoming invoices in one line.

All fields, findings and limits are in the documentation.

[**Reading in the docs**](https://quittio.dev/en/docs/reading) [**E-invoices with PHP**](https://quittio.dev/en/php)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://quittio.dev/en#website","@type":"WebSite","description":"E-invoicing for PHP and Laravel: create, validate, read and archive ZUGFeRD, XRechnung and Peppol invoices.","inLanguage":"en","name":"Quittio","url":"https://quittio.dev/en","publisher":{"@id":"https://quittio.dev/#identity"},"translationOfWork":{"@id":"https://quittio.dev/#website"}},{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#webpage","@type":"WebPage","dateModified":"2026-11-13","datePublished":"2026-11-13","description":"Read incoming e-invoices in PHP: extract the XML from a ZUGFeRD PDF, read XRechnung in CII and UBL, validate it and check the totals. With a code example.","name":"Read ZUGFeRD and XRechnung invoices with PHP","url":"https://quittio.dev/en/guides/read-e-invoices-with-php","breadcrumb":{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#breadcrumb"},"isPartOf":{"@id":"https://quittio.dev/en#website"},"potentialAction":[{"@type":"ReadAction","target":["https://quittio.dev/en/guides/read-e-invoices-with-php"]}],"primaryImageOfPage":{"@id":"https://quittio.dev/#logo"}},{"@id":"https://quittio.dev/#identity","@type":"Organization","description":"Open-Source-Bibliothek für E-Rechnungen in PHP und Laravel (ZUGFeRD, XRechnung, Peppol) und Quittio Managed.","email":"kontakt@niklasforst.de","legalName":"Niklas Forst – Softwareentwicklung","name":"Quittio","url":"https://quittio.dev","founder":{"@type":"Person","name":"Niklas Forst","url":"https://quittio.dev/ueber"},"logo":{"@id":"https://quittio.dev/#logo"},"sameAs":["https://github.com/Quittio/quittio","https://packagist.org/packages/quittio/quittio"]},{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#article","dateModified":"2026-11-13","datePublished":"2026-11-13","description":"Read incoming e-invoices in PHP: extract the XML from a ZUGFeRD PDF, read XRechnung in CII and UBL, validate it and check the totals. With a code example.","headline":"Read incoming e-invoices with PHP","inLanguage":"en","thumbnailUrl":"https://quittio.dev/og/ratgeber-lesen-en-16x9.jpg","@type":["Article","TechArticle"],"author":{"@id":"https://quittio.dev/#/schema/person/1"},"image":["https://quittio.dev/og/ratgeber-lesen-en-16x9.jpg","https://quittio.dev/og/ratgeber-lesen-en-4x3.jpg","https://quittio.dev/og/ratgeber-lesen-en-1x1.jpg"],"isPartOf":{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#webpage"},"mainEntityOfPage":{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#webpage"},"publisher":{"@id":"https://quittio.dev/#identity"}},{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://quittio.dev/en","position":1},{"@type":"ListItem","name":"Guides","item":"https://quittio.dev/en/guides","position":2},{"@type":"ListItem","name":"Reading","position":3}]},{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#/schema/question/1","@type":"Question","inLanguage":"en","name":"Can I read ZUGFeRD invoices without Laravel?","acceptedAnswer":{"@type":"Answer","text":"Yes. read(), readFile() and validateFile() are part of quittio/core and run in any project with PHP 8.3. The page E-invoices with PHP gives an overview."}},{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#/schema/question/2","@type":"Question","inLanguage":"en","name":"Do I have to extract the XML from the PDF myself?","acceptedAnswer":{"@type":"Answer","text":"No. Quittio finds the embedded XML of a ZUGFeRD or Factur-X PDF and reads it. embeddedFilename shows its file name."}},{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#/schema/question/3","@type":"Question","inLanguage":"en","name":"Does Quittio correct wrong totals?","acceptedAnswer":{"@type":"Answer","text":"No. The values stay as stated in the document. Quittio reports differences from the recalculation as warning QUITTIO-DECLARED-TOTALS."}},{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#/schema/question/4","@type":"Question","inLanguage":"en","name":"Does Quittio read ZUGFeRD 1.0?","acceptedAnswer":{"@type":"Answer","text":"No. ZUGFeRD 1.0 does not conform to EN 16931 and is rejected with a clear message."}},{"@id":"https://quittio.dev/en/guides/read-e-invoices-with-php#/schema/question/5","@type":"Question","inLanguage":"en","name":"Can I safely read uploads from unknown senders?","acceptedAnswer":{"@type":"Answer","text":"Quittio rejects XML with a DOCTYPE, limits sizes and PDF structures and never uses embedded file names as paths. Still validate the invoice before you book it."}},{"@id":"https://quittio.dev/#/schema/person/1","@type":"Person","name":"Niklas Forst","url":"https://quittio.dev/ueber"},{"@id":"https://quittio.dev/#logo","@type":"ImageObject","caption":"Quittio","contentUrl":"https://quittio.dev/logo.png","inLanguage":"en","url":"https://quittio.dev/logo.png"}]}
```