Endroid QR Code
Generate QR codes as PNG, SVG, EPS, WebP, or binary in PHP
Repository Health
Technical Analysis
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
Builderclass exposing every generation option (data, size, margin, error-correction level, encoding, colors, logo, label) as named constructor parameters with sensible defaults - Multiple
Writerimplementations 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
OpenSansfont class) and alignment - An optional result validator that decodes the freshly generated image via
khanamiryan/qrcode-detector-decoderto 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-bundlefor 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.
Used by 4 apps in this directory
Invoice Ninja
Invoicing Finance · Project Management
Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.
Kimai
Invoicing Finance · Project Management
Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.
Leantime
Productivity · Project Management · Collaboration
Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira
Pixelfed
Social Media
A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.