Download the PHP package phpdot/qrcode without Composer
On this page you can find all versions of the php package phpdot/qrcode. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpdot/qrcode
More information about phpdot/qrcode
Files in phpdot/qrcode
Informations about the package qrcode
phpdot/qrcode
Coroutine-safe QR code generation for the PHPdot ecosystem. Encode any string to a QR symbol and render
it as SVG (a pure string, no extension), PNG (GD), a raw module matrix, or an inline data:
URI — through one immutable, injectable factory. Encoding is delegated to the battle-tested
bacon/bacon-qr-code (numeric, alphanumeric, byte and Kanji
modes, ECI, all four error-correction levels, versions 1–40, automatic masking); everything bacon touches
is fenced behind a single Encoder, and the rest of the package — the value objects, the renderers, the
fluent builder — is plain PHPdot code.
Table of Contents
- Requirements
- Installation
- Usage
- Architecture
- Testing
- License
Requirements
| Requirement | Constraint |
|---|---|
| PHP | >= 8.5 |
ext-gd |
* |
bacon/bacon-qr-code |
^3.0 |
ext-gd is used only by the PNG renderer; SVG, the data URI, and the raw matrix need no extension.
Installation
Usage
One-call helpers
Inject QrCodeFactory and call a format helper — each encodes with sensible defaults and returns the
bytes directly:
svg(), png(), and dataUri() cover the common cases; make() returns the encoded QrCode value
object without rendering, and create() opens a fluent build for anything more.
The fluent builder
create() returns an immutable QrCodeBuilder — every setter returns a new builder, so a configured
builder is a safe reusable template. Terminal methods (toSvg(), toPng(), toDataUri(), toMatrix(),
encode()) produce the output:
Colors and options
Color is an immutable RGBA value object with channels validated to 0–255; RenderOptions carries the
size (target square edge in pixels, default 300) and margin (quiet-zone width in modules, default
4):
Encoding and ECI
Byte-mode content defaults to UTF-8 with an ECI segment, the specification-correct way to signal a
non-ISO-8859-1 charset. Most modern scanners read it fine; for legacy hardware scanners that cannot,
disable it with eci(false). ASCII content (URLs, numbers) is unaffected.
Architecture
QrCodeFactory is the injected #[Singleton] entry point; it hands out immutable QrCodeBuilder
instances. A build asks Encoder — the single boundary to bacon/bacon-qr-code — to produce a QrCode
carrying an immutable Matrix, then passes that matrix plus RenderOptions to a RendererInterface. The
SVG renderer is a pure string (non-blocking, the default); the PNG renderer is a CPU-bound GD raster; the
data-URI renderer wraps either and base64-encodes the result.
Testing
The PNG renderer is covered by a pixel round-trip test: a symbol is rendered, its pixels are read back, the matrix is reconstructed, and it is asserted equal to the source — so a renderer that painted the wrong cells fails even though the encoder itself is trusted.
License
MIT — see LICENSE.
This repository is a read-only mirror. The canonical source lives in phpdot/monorepo; pull requests and issues are handled there: pulls · issues.