Endroid QR Code

Generate QR codes as PNG, SVG, EPS, WebP, or binary in PHP

Library
Composer
v6.1.3
4,805stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
48/100Fair
Development Activity4
Maintenance0
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture80
Code Quality76
Innovation68
Learning Curve84

Endroid QR Code is a PHP library for generating QR codes with fine-grained control over appearance and output format, built on top of bacon/bacon-qr-code for the underlying matrix encoding. It exposes both a Builder class for the common configuration path (data, size, margin, error-correction level, colors, embedded logo, text label) and a lower-level QrCode/writer API for callers who want to construct each piece manually.

A dedicated Writer layer supports multiple output formats from the same encoded matrix — PngWriter and WebPWriter (via the GD extension), SvgWriter, EpsWriter, PdfWriter (vector formats suitable for print), BinaryWriter for raw bit output, and even a ConsoleWriter/DebugWriter for terminal preview during development. The library also supports embedding a logo image inside the code with configurable resizing and background punch-out, custom fonts for text labels, and an optional round-trip validator (via khanamiryan/qrcode-detector-decoder) that decodes the generated image to confirm it’s actually scannable before returning it.

What You Get

  • A Builder class exposing every generation option (data, size, margin, error-correction level, encoding, colors, logo, label) as named constructor parameters with sensible defaults
  • Multiple Writer implementations for the same encoded QR matrix — PNG and WebP via GD, SVG and EPS for vector output, PDF, raw binary, plus console/debug writers for terminal preview
  • Logo embedding with configurable resize width and background punch-out so the code remains scannable around an inset logo
  • Custom label text rendering with configurable font (bundled OpenSans font class) and alignment
  • An optional result validator that decodes the freshly generated image via khanamiryan/qrcode-detector-decoder to confirm scannability before returning it

Common Use Cases

  • Generating scannable QR codes for URLs, payment links, or Wi-Fi credentials in web applications
  • Embedding branded logos inside QR codes for marketing materials while keeping the code readable
  • Producing print-ready vector QR codes (SVG/EPS/PDF) for posters, packaging, or business cards
  • Symfony applications using the companion endroid/qr-code-bundle for route-based QR code generation and Twig integration

Under The Hood

Architecture — The library separates concerns into three layers: src/Encoding/src/Matrix produce the raw QR bit-matrix (delegating the actual encoding algorithm to bacon/bacon-qr-code), src/Builder/Builder.php is a facade that assembles a QrCode value object plus rendering options from a single constructor call, and src/Writer/ contains one class per output format (PngWriter, SvgWriter, EpsWriter, PdfWriter, WebPWriter, BinaryWriter, ConsoleWriter) each implementing a shared WriterInterface so any writer can consume the same matrix and options. Tech Stack — PHP 8.4+ with bacon/bacon-qr-code ^3.0 as the sole required runtime dependency; the GD extension is optional (needed only for PNG/WebP output), and setasign/fpdf and khanamiryan/qrcode-detector-decoder are optional dev/suggested packages for PDF writing and result validation respectively. Code Quality — The codebase enforces strict typing throughout with per-concern class separation (Color/, Label/, Logo/, Exception/), and ships an endroid/quality dev-dependency for internal static-analysis/style tooling; test coverage (3 top-level test classes plus nested writer/builder specs) is comparatively light relative to the number of writer implementations, though the core matrix-generation logic is delegated to the well-tested bacon/bacon-qr-code dependency. API Design — The Builder constructor takes every option as a named parameter with defaults, so a minimal call needs only a writer and data string while advanced use (logo, label, error correction, custom colors) is opt-in without cluttering the common path; swapping output format is a one-line change (pass a different Writer implementation) rather than touching any encoding logic.

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