Swiss QR Bill

A PHP library to create standards-compliant Swiss QR bill payment parts (QR-Rechnung).

Library
Composer
vv5.3
331stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
52/100Fair
Development Activity4
Maintenance44
Community80
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture84
Code Quality84
Innovation72
Learning Curve74

Swiss QR Bill is a PHP library for creating Swiss QR bill payment parts, the QR-Rechnung / QR-facture that replaced the old orange and red payment slips in Switzerland. It builds the payment part and receipt according to the official Swiss Payment Standards, generating the Swiss Cross QR code that encodes creditor, debtor, amount, and reference information.

The library validates all input against the QR bill specification using Symfony’s validator, so malformed IBANs, references, or amounts are caught before output. It can render the result as HTML, or as a printable PDF via supported PDF backends such as FPDF and TCPDF, producing a slip that Swiss banks and payment apps can scan.

What You Get

  • A QrBill builder assembled from typed data groups (creditor, debtor, amount, reference)
  • Specification-compliant Swiss QR code generation with the Swiss Cross
  • Validation of IBANs, QR/SCOR references, and amounts against the QR bill standard
  • PDF output through supported backends (FPDF, TCPDF) plus HTML rendering
  • Support for QR-IBAN with QR reference, classic IBAN with SCOR reference, or no reference

Common Use Cases

  • Generating QR bill invoices for Swiss customers from an accounting or ERP system
  • Producing printable PDF payment slips attached to invoices or letters
  • Creating scannable payment parts for CHF and EUR transactions in Switzerland and Liechtenstein
  • Validating payment reference and IBAN data before issuing a bill

Under The Hood

Architecture - The QrBill aggregate (src/QrBill.php) composes DataGroup value objects (creditor information, payment amount, payment reference) that map to the specification’s sections. A Validator layer built on Symfony constraints enforces spec rules, QrCode wraps endroid/qr-code to render the Swiss Cross code, and PaymentPart output classes drive HTML and PDF rendering. Reference and String helpers handle QR/SCOR reference formatting and text normalization.

Tech Stack - PHP 8.1-8.5 library distributed as sprain/swiss-qr-bill. It requires ext-dom and ext-bcmath and depends on symfony/validator and symfony/intl for validation and localization, kmukku/php-iso11649 for reference checks, and endroid/qr-code for QR generation. FPDF and TCPDF are supported as pluggable PDF backends. PHPStan and Rector support static analysis and refactoring.

Code Quality - The code is cleanly separated into data groups, constraints, and output layers, with a focused test suite (24 test files) and PHPStan configured. Validation logic is declarative via Symfony constraints, and the domain model closely follows the published Swiss Payment Standards, improving correctness confidence.

API Design - Assembly is explicit but readable: you create typed data groups and attach them to a QrBill, then call an output class for HTML or PDF. Extensive examples in the repo (minimal, SCOR, full) shorten onboarding, and the strong validation surfaces mistakes early, keeping the learning curve moderate for developers new to the QR-bill spec.

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