Download the PHP package tonsoo/php-qr-code without Composer
On this page you can find all versions of the php package tonsoo/php-qr-code. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tonsoo/php-qr-code
More information about tonsoo/php-qr-code
Files in tonsoo/php-qr-code
Package php-qr-code
Short Description A library for generating qr-codes in various formats and configurations
License MIT
Informations about the package php-qr-code
tonsoo/php-qr-code
A QR code styling and rendering library for PHP.
tonsoo/php-qr-code separates QR encoding from styling and rendering so the package can focus on how a QR code looks: module shapes, finder styling, logo placement, SVG output, and raster output.
Status
Current focus:
- Matrix encoding through
bacon/bacon-qr-code - Styling through
QRCode,ModuleStyle,EyeStyle, andLogo - SVG output with vector-native shape rendering
- PNG/JPEG/WebP output through GD
- Center logo support with safety validation
- CLI example under
examples/cli.php
Installation
For raster output you also need GD:
Quick Start
Helper API
Factory API
Public API
Creation
qrCode(string $data): QRCodeQRCodeFactory::create(string $data): QRCode(new QRCodeFactory())->make(string $data): QRCodeQRCode::fromMatrix(MatrixInterface $matrix, ErrorCorrection $errorCorrection = ErrorCorrection::Medium): QRCode
QRCode styling
->size(int $pixels)->margin(int $pixels)->background(string $color)->foreground(string $color)->modules(ModuleStyle $style)->eyes(EyeStyle $style)->eyePupils(ModuleStyle $style)->style(ModuleType $type, ModuleStyle $style)->logo(Logo $logo)
Output
->toSvg()->toPng()->toJpeg()->toWebp()->save(string $path)->render(RendererInterface $renderer)
Shapes
Built-in module shapes:
ModuleStyle::square()ModuleStyle::circle()ModuleStyle::rounded(float $roundness = 0.35)ModuleStyle::classyRounded(float $roundness = 0.85)ModuleStyle::diamond()ModuleStyle::custom(Closure $callback, ?ShapeSafety $safety = null, string $name = 'custom')
classy-rounded is neighbor-aware and is intended to approximate the popular QR styling variants used by tools such as Mini QR / qr-code-styling.
Custom shapes
Custom shapes receive a ShapeContext and return a vector Path.
Logos
Logos are placed in the center of the QR code and reserve a clean exclusion area behind them.
SVG logo handling
SvgRenderer supports four logo modes through SvgLogoMode:
SvgLogoMode::AutoSvgLogoMode::PathSvgLogoMode::DataUriSvgLogoMode::InlineSvg
Auto is the default. SVG files are normally inlined as nested SVG so the final output stays vector-native.
Error Correction
The package uses the four QR standard levels:
ErrorCorrection::LowErrorCorrection::MediumErrorCorrection::QuartileErrorCorrection::High
Higher correction improves resilience but there is no level above High in the QR standard.
CLI Example
The repository ships with a minimal CLI in examples/cli.php.
Logo example:
Show all options:
Architecture
The package is split into a few layers:
Encoding/: QR matrix generation adaptersMatrix/: matrix abstractionLayout/: classifies dark modules into finder/data/timing/alignment typesShapes/andGeometry/: shape logic and reusable vector geometryStyling/: expressive styling objects used by the public APIRendering/: SVG and GD renderersValidation/: safety checks such as logo coverage validation
Automated Tests
The repository uses PHPUnit.
Run all tests:
or directly:
Covered areas currently include:
- matrix validation
- logo placement helpers
- SVG renderer basics
- logo safety validation
- enum-backed renderer options
Notes
- SVG rendering is the primary path for advanced styling.
- Raster rendering currently supports the core built-in shapes and depends on GD.
- Large logos or aggressive padding are intentionally rejected when they are likely to make the QR unreadable.