Barcode and QR code generation and reading library for PHP 8.1+.
Encodes data into 1D and 2D barcode symbologies and renders them as HTML, raster images (via horde/Image), SVG or PDF (via horde/Pdf). Decodes barcodes from module matrices and bar patterns back into structured data. Includes a semantic layer for some popular structured payload formats (payments, contacts, WiFi, GS1, healthcare, etc.) with bidirectional encode/decode support.
Status: Encoding and rendering are fully implemented. Reading/decoding from images is designed (interfaces defined) but not yet implemented. Contributions welcome. :)
use Horde\Barcode\Barcode;
// QR code as HTML table
echo Barcode::qrHtml('https://www.horde.org/');
// Code 128 as HTML
echo Barcode::code128Html('INV-2026-0042');
// EAN-13 as HTML
echo Barcode::eanHtml('5901234123457');
// Data Matrix as HTML
echo Barcode::dataMatrixHtml('Serial:ABC123');- PHP 8.1+ with ext-mbstring
- No other required dependencies (HTML renderer is standalone)
horde/imagefor raster (PNG/JPEG) and SVG outputhorde/pdffor PDF outputhorde/otpfor OTP provisioning URI generation
composer require horde/barcode| Class | Standard | Common Name | Description |
|---|---|---|---|
QrEncoder |
ISO/IEC 18004 | QR Code | 2D matrix barcode, versions 1–40, EC levels L/M/Q/H |
DataMatrixEncoder |
ISO/IEC 16022 | Data Matrix | 2D matrix barcode, ECC200 error correction |
Code128Encoder |
ISO/IEC 15417 | Code 128 | High-density linear barcode, character sets A/B/C |
EanUpcEncoder |
ISO/IEC 15420 | EAN/UPC | Retail point-of-sale (EAN-13, EAN-8, UPC-A, UPC-E) |
Code39Encoder |
ISO/IEC 16388 | Code 39 | Alphanumeric linear barcode (A–Z, 0–9, symbols) |
Itf14Encoder |
ISO/IEC 16390 | ITF-14 | Interleaved 2-of-5 for shipping cartons |
| Class | Format | Use Case | Reference |
|---|---|---|---|
OtpProvisioning |
otpauth:// URI | TOTP/HOTP provisioning | Google Authenticator Key URI |
WiFi |
WIFI:…;; | WiFi network sharing | WPA3 / Wi-Fi Alliance |
VCard |
MECARD:…;; | Contact sharing | NTT DoCoMo MeCard |
Url |
HTTP/HTTPS URL | Web links | RFC 3986 |
Email |
mailto: URI | Email composition | RFC 6068 |
Sms |
smsto: URI | SMS composition | RFC 5724 |
Tel |
tel: URI | Phone dialing | RFC 3966 |
SepaEpc |
EPC069-12 | EU SEPA credit transfer | European Payments Council |
EmvQr |
EMVCo Merchant QR | Payment terminal QR | EMVCo QR Specification |
Pix |
BCB Pix | Brazilian instant payments | Banco Central do Brasil |
Upi |
UPI Deep Link | Indian instant payments | NPCI UPI |
Gtin |
GTIN-8/12/13/14 | Product identification | GS1 GTIN |
Gs1Barcode |
GS1 AI Element Strings | Supply chain data | GS1 General Specifications |
DigitalLink |
GS1 Digital Link URI | Web-resolvable product IDs | GS1 Digital Link |
IataBcbp |
IATA Resolution 792 | Airline boarding passes | IATA BCBP |
Udi |
FDA 21 CFR 830 / EU MDR | Medical device identification | FDA UDI |
Hibc |
ANSI/HIBC 2.6 | Healthcare product labeling | HIBCC |
See doc/USAGE.md for full API documentation and examples.
LGPL-2.1 — see LICENSE.