zugferd

Create, read, and validate European electronic invoices in PHP

Library
Composer
vv1.0.124
433stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity92
Maintenance100
Community72
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture84
Code Quality82
Innovation80
Learning Curve68

horstoeko/zugferd is a PHP library for creating and reading European electronic invoices in the ZUGFeRD, XRechnung, and Factur-X standards. It lets you build compliant hybrid PDF/A-3 invoices with embedded EN 16931 XML, parse existing electronic invoices back into structured data, and validate documents against the relevant schemas and business rules.

Covering the full range of ZUGFeRD profiles from MINIMUM to EN 16931 and EXTENDED, the library abstracts the complex Cross-Industry Invoice XML behind an expressive builder and reader API, making it practical for German and wider EU e-invoicing compliance.

What You Get

  • A fluent ZugferdDocumentBuilder for assembling compliant invoice documents
  • Readers that parse ZUGFeRD/Factur-X XML and hybrid PDFs back into structured data
  • PDF/A-3 generation that embeds the invoice XML into a human-readable PDF
  • Schema (XSD) and KOSIT-based validation across all supported invoice profiles

Common Use Cases

  • Generating legally compliant e-invoices for German and EU B2B and B2G transactions
  • Reading and extracting structured data from incoming electronic invoices
  • Validating invoice documents against EN 16931 and XRechnung business rules

Under The Hood

Architecture - The domain is modeled as JMS-serializer entities generated from the official XSD schemas (src/entities, src/schema). ZugferdDocumentBuilder exposes a fluent API that populates these entities and serializes them to Cross-Industry Invoice XML via jms/serializer; ZugferdDocumentReader reverses the process. PDF handling layers on top through ZugferdDocumentPdfBuilder, which uses FPDF/FPDI to produce PDF/A-3 files with the XML embedded, while ZugferdKositValidator shells out to the KOSIT validator for XRechnung conformance. Profiles and specification versions are resolved through ZugferdProfileResolver and ZugferdProfiles.

Tech Stack - PHP 7.3+ with the dom, libxml, simplexml, zip, and fileinfo extensions, built on jms/serializer, symfony components (validator, finder, process, yaml), setasign/fpdf and fpdi for PDF output, and smalot/pdfparser for reading. The large XSLT footprint holds the schema and validation stylesheets.

Code Quality - The project is actively maintained with frequent releases and a broad dev toolchain (PHPUnit with 50+ test files, PHPStan, PHPMD, phpcpd, pdepend, rector). Much of the entity layer is generated from schemas, keeping it consistent with the standards, and CI enforces builds on every change.

API Design - The builder/reader pairing gives an approachable entry point, but the domain itself is inherently complex: EN 16931 defines a large number of fields and constraints, so real-world use requires familiarity with the invoicing standards. Extensive examples and quick-builder helpers in src/quick ease onboarding, though the learning curve reflects the domain rather than the API.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search