horde/barcode

Horde Barcode and QR Code Rendering and Parsing Library

Maintainers

Package info

github.com/horde/Barcode

Homepage

pkg:composer/horde/barcode

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0alpha1 2026-05-12 00:00 UTC

This package is auto-updated.

Last update: 2026-05-12 15:57:43 UTC


README

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. :)

Quick Start

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');

Requirements

  • PHP 8.1+ with ext-mbstring
  • No other required dependencies (HTML renderer is standalone)

Optional

  • horde/image for raster (PNG/JPEG) and SVG output
  • horde/pdf for PDF output
  • horde/otp for OTP provisioning URI generation

Installation

composer require horde/barcode

Supported Standards

Barcode Symbologies

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

Semantic Payload Formats

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

Documentation

See doc/USAGE.md for full API documentation and examples.

License

LGPL-2.1 — see LICENSE.