Skip to content
CAI
Software that uses CAICheck a score

endroid/qr-code

64.0

Adequate · 19 September 2026

1.9k

lines of production code

PHP

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a PHP library for generating QR codes, providing a structured API to configure data, encoding, error correction, and visual styling. It supports embedding logos and text labels, with robust validation to ensure data integrity and proper block sizing. The library renders outputs into multiple formats, including images (PNG, SVG, WebP), documents (PDF, EPS), and console or binary text.

How it got here

2012–2015 — Initial release and API redesign

3 changes.

This period marks the initial release of the Endroid QR Code library, establishing its core PHP structure and dependencies. The work focused on a significant architectural shift from a mutable builder pattern to an immutable QrCode model with new configuration enums. Comprehensive test suites were added to validate the new API, ensuring correct generation and readability across various formats and data types.

2017–2021 — API expansion and output format support

9 changes.

This period focused on significantly expanding the library's capabilities through a new Builder API and enhanced Writer modules. Key developments included support for embedding logos and text labels, broadening output formats to include PDF, SVG, EPS, and console outputs, and introducing stricter validation for encodings and block sizes.

Features

Add hex color getter to Color class

The Color class now includes a getHex() method that returns the color as a hexadecimal string (e.g., '\#RRGGBB'), complementing the existing RGB and alpha accessors. This allows users to easily obtain a standard hex representation of QR code colors for use in HTML, CSS, or other systems that expect hex color codes.

src/Color · high confidence

Introduce new Label component with font, margin, and alignment support

This change adds a new Label component to the library, allowing users to attach text labels to QR codes. The implementation includes a \Label\ class that supports configurable text, font (via \FontInterface\ with a default OpenSans font), alignment (center, left, right), margin (top, right, bottom, left), and text color. The component is structured with dedicated interfaces and classes for fonts and margins, providing a flexible API for customizing label appearance.

src/Label · high confidence

New Builder API for QR code generation

The src/Builder directory introduces a new Builder API, including the Builder class, BuilderInterface, BuilderRegistry, and BuilderRegistryInterface. This provides a structured way to configure and generate QR codes with options for data, encoding, error correction, size, colors, labels, and logos, along with a registry for managing multiple builder instances.

src/Builder · high confidence

New exception classes for block size and validation errors

The library now includes two new exception classes to provide more specific error handling: BlockSizeTooSmallException is introduced to signal when a QR code block size is insufficient, and ValidationException is added with factory methods to report issues such as unsupported writers, missing validation packages, or data mismatches during result verification.

src/Exception · high confidence

New label and logo image data classes with improved error handling

The src/ImageData directory now includes LabelImageData and LogoImageData classes to manage image data for labels and logos. LabelImageData validates that label text does not contain line breaks and ensures the FreeType extension is available. LogoImageData handles logo image loading, including support for SVG logos (which require explicit width and height), automatic MIME type detection from URLs or file paths, and a new punchout background feature. It also provides robust error handling for file reading, image parsing, and MIME type detection, ensuring clearer error messages when issues occur.

src/ImageData · high confidence

New logo support and expanded writer capabilities

The Writer module now supports embedding logos into QR codes via a new Logo model and LogoInterface, with background punchout functionality available for GD-based formats (PNG, GIF, WebP) and basic embedding for PDF and SVG (punchout is explicitly unsupported in SVG). Several writers have been updated or added: the SVG writer now supports compact path generation, block definitions, and options to exclude XML declarations or width/height attributes; the PDF writer adds support for embedding logos and clickable links; the PNG writer introduces compression level and color count options; and new writers for Binary, Console, Debug, and EPS outputs have been introduced to broaden output formats.

src/Writer · high confidence

New result classes for console, binary, debug, EPS, and PDF output formats

The library now provides dedicated result classes to render QR codes as plain text for terminal consoles (ConsoleResult), raw binary strings (BinaryResult), structured debug information (DebugResult), Encapsulated PostScript (EpsResult), and PDF documents (PdfResult). These additions expand the available output formats beyond the existing image-based results, allowing users to print QR codes directly to the command line, export vector graphics, or generate printable PDF files.

src/Writer/Result · high confidence

Behavioural changes

Introduces new immutable QrCode model and configuration enums

The library now uses a new, immutable \QrCode\ value object (implementing \QrCodeInterface\) to represent QR code data, replacing the previous mutable builder pattern. This model is configured via new enums: \ErrorCorrectionLevel\ (with cases High, Low, Medium, Quartile) and \RoundBlockSizeMode\ (with cases Enlarge, Margin, None, Shrink). Users must now construct QR codes using this new class constructor, which accepts parameters for data, encoding, error correction level, size, margin, round block size mode, and foreground/background colors.

src · high confidence

New Matrix class throws exception when block size is too small

The new Matrix class now validates that the calculated block size is at least 1 during construction. If the QR code data is too large for the given dimensions or error correction level, resulting in a block size smaller than 1, a BlockSizeTooSmallException is thrown with a message suggesting the user increase image dimensions or lower the error correction level.

src/Matrix · high confidence

Strict encoding validation with mbstring requirement for non-UTF-8

The Encoding component now enforces strict validation when a non-UTF-8 encoding is specified. If the mbstring extension is not installed, the system throws an exception immediately. If mbstring is present but the requested encoding is not in the list of supported encodings, a specific error is raised listing valid options. This ensures that only valid, supported encodings are used, preventing silent failures or undefined behavior in QR code generation.

src/Encoding · high confidence

Test coverage

Added comprehensive test suite for QR code generation and validation

Added new test files (BuilderTest, QrCodeTest, ValidatorTest) and test assets to verify the QR code library's functionality. The tests cover the new Builder API, ensuring correct output for various writers (PNG, SVG, WebP, GIF, PDF, EPS, Binary, Console, Debug) and result types. They also validate specific behaviors such as size and margin calculations with rounded block modes, error handling for invalid logo paths and data, file saving capabilities, label line break restrictions, and block size constraints. Additionally, the ValidatorTest ensures that generated QR codes are readable across diverse data inputs, including special characters, URLs, and non-Latin scripts.

tests · high confidence

Dependencies

Initial release of Endroid QR Code library

This change introduces the initial composer.json for the Endroid QR Code library, establishing it as a PHP library requiring PHP 8.4 and the bacon/bacon-qr-code package (version 3.0). It configures PSR-4 autoloading for the src/ and tests/ directories, sets up development dependencies including the GD extension, quality tools, and optional readers/writers (khanamiryan/qrcode-detector-decoder and setasign/fpdf), and defines a branch alias for the 6.x development line.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 64.

Lenses

  • Code Health 99
  • Architecture 100
  • Maturity 51
  • Readiness 55
  • Security 95

Changes since last survey

  • 300 commits — 251 feature/other, 49 fixes

By area

  • (root) — 105 commits
  • src/Writer — 80 commits
  • (repo) — 32 commits
  • .github/workflows — 27 commits
  • src/Builder — 9 commits
  • src/ImageData — 8 commits
  • tests/QrCodeTest.php — 7 commits
  • src/QrCode.php — 6 commits
  • src/Exception — 5 commits
  • src/ErrorCorrectionLevel.php — 3 commits
  • tests/output — 3 commits
  • .github/FUNDING.yml — 2 commits
  • src/Color — 2 commits
  • src/Encoding — 2 commits
  • tests/BuilderTest.php — 2 commits
  • src/Factory — 1 commit
  • src/Label — 1 commit
  • src/Logo — 1 commit
  • src/Matrix — 1 commit
  • src/Response — 1 commit

Notable commits

  • fix: Bugfix: Lower-case HTTP header parameters (#454)
  • fix: Compact SVGs and fix block spacing issue
  • fix: Fix CS
  • fix: Fix CS
  • fix: Fix CS
  • fix: Fix CS
  • fix: Fix CS
  • fix: Fix CS
  • fix: Fix CS
  • fix: Fix EPS upside down issue
  • fix: Fix PHPStan error
  • fix: Fix QA
  • fix: Fix and simplify punchout background calculation
  • fix: Fix blurryness issue
  • fix: Fix check
  • fix: Fix composer syntax
  • fix: Fix creation detection
  • fix: Fix error check
  • fix: Fix error correction level handling
  • fix: Fix gitattributes
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

endroid/qr-code was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 5fa534856ed95649d67c0eab0cabc03ab1d8e0e2 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.