chillerlan/php-qrcode

PHP library for generating and reading QR codes with a user-friendly API

Library
Composer
v6.0.1
2,384stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
63/100Good
Development Activity32
Maintenance48
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture80
Code Quality82
Innovation65
Learning Curve72

chillerlan/php-qrcode is a PHP QR code generator and reader, built on a cleaned-up, namespaced fork of Kazuhiko Arase’s original QR code implementation, with a reader based on a PHP port of Google’s ZXing library. It supports Model 2 QR codes from version 1 to 40, all four error-correction levels (L/M/Q/H), and mixed encoding modes within a single symbol (numeric, alphanumeric, 8-bit binary with ECI, and 13-bit kanji/hanzi double-byte).

Output is handled through a pluggable output-module system covering GdImage raster formats (PNG, JPEG, WebP, AVIF, GIF, BMP), ImageMagick, SVG/HTML markup, plain-text/JSON string output, EPS, and PDF via FPDF — plus the reverse direction, decoding QR codes from images via GD or ImageMagick. It requires PHP 8.4+ and has a companion JavaScript port published separately on npm.

What You Get

  • QR code generation for Model 2 symbols, versions 1-40, with ECC levels L/M/Q/H
  • Mixed encoding modes in a single symbol: numeric, alphanumeric, 8-bit binary (with ECI), kanji, and hanzi
  • Pluggable output modules: GdImage raster formats, ImageMagick, SVG/HTML, JSON/plain text, EPS, and PDF via FPDF
  • A QR code reader/decoder (ZXing-derived) that works via GD or ImageMagick
  • A fluent QROptions configuration object for customizing size, margins, colors, and output format

Common Use Cases

  • Generating QR codes for URLs, payment links, Wi-Fi credentials, or vCards in a PHP web application
  • Embedding QR codes into generated PDFs (tickets, invoices, boarding passes) via the FPDF output module
  • Building a two-factor authentication (2FA) setup flow that renders a scannable QR code for authenticator apps
  • Decoding QR codes uploaded by users (e.g. scanned receipts or tickets) server-side without a JavaScript-based scanner

Under The Hood

Architecture The library separates concerns into Data/ (encoding-mode-specific encoders), Common/ (QR matrix construction, masking, error correction), Output/ (one class per output format implementing a shared interface), and Decoder/Detector (the ZXing-derived reader pipeline), all orchestrated through the central QRCode class and a QROptions/QROptionsTrait configuration object. Tech Stack Requires PHP 8.4+ and ext-mbstring, with chillerlan/php-settings-container providing the typed options-object base class; optional dependencies (ext-gd, ext-imagick, setasign/fpdf, intervention/image) are only needed for the specific output formats a consumer uses. Code Quality The test suite spans 58 files under tests/, run via PHPUnit with Codecov coverage tracking in CI, and the project layers PHPStan, Phan, PHPMD, and PHP_CodeSniffer (with a phpstan-baseline.neon for gradual strictness) plus PHPBench-based performance benchmarks. API Design The primary entry point is a single QRCode object configured via a typed QROptions instance and rendered with one render()/getRawData() call; adding a new output format means implementing one interface, and mixed-mode encoding is handled transparently by the encoder without requiring the caller to pre-segment input strings.

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