chillerlan/php-qrcode
PHP library for generating and reading QR codes with a user-friendly API
Repository Health
Technical Analysis
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
QROptionsconfiguration 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.
Used by 2 apps in this directory
Appwrite
Developer Tools · Databases · Authentication
Open-source backend platform with Auth, Databases, Storage, Functions, Messaging, Realtime, and Sites — deploy via Docker or use Appwrite Cloud.
EspoCRM
Marketing · Ecommerce · CRM
Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.