Open source
QR for Laravel
composer require roundly-consulting/qr-for-laravelOverview
Native QR codes for Laravel: an ISO/IEC 18004 encoder, one optimised SVG renderer, and typed payloads for links, contacts, Wi-Fi, 2FA setup codes, SEPA credit transfers (EPC069-12) and Slovak PAY by square payments. Invalid content is refused before a code is drawn, and secrets such as 2FA seeds are never cached. Everything is implemented inside the package — no third-party QR, image or compression library, only Laravel and Roundly’s own companion packages. MIT-licensed.
What you get
Native ISO/IEC 18004 encoder
QR Code Model 2, versions 1–40, levels L/M/Q/H, optimal numeric/alphanumeric/byte/kanji segmentation and ECI 26 for UTF-8.
One optimised SVG
A single even-odd path with an exact viewBox — square, rounded or dot modules, rounded finders and an accessible title and description.
Typed payloads
Text, URL, e-mail, phone, SMS, Wi-Fi, vCard, geo and otpauth — validated before a code is drawn, without leaking the value into errors.
SEPA & PAY by square
EPC069-12 v3.1 credit transfers and PAY by square 1.0.0–1.2.0 orders, standing orders and direct debits — encode and decode.
Banking primitives
IBAN, BIC and ISO 11649 creditor reference value objects, validation rules and an AsIban Eloquent cast.
Sensitivity-aware caching
2FA seeds and Wi-Fi passwords are never memoised, cached or served cacheably; public codes get ETags and an optional SVG cache.
Facade or DI, Laravel-native output
Call the Qr facade or inject QrFactory; return a code from a controller, drop <x-qr-code> into Blade, embed a data URI or run qr:make.
Documentation
Installation
Install via Composer — no migrations, no routes; optionally publish the config and the translations.
Configuration
Every config key, default and env variable — error correction, versions, SVG styling, caching, Blade and payment standards.
The Qr facade
Every method on the Qr facade — typed payload entry points, one-call svg/matrix/info shortcuts and the cheap fits() capacity check.
Without the facade
Inject the QrFactory contract instead of calling the Qr facade — the same API as an explicit constructor dependency, with no static calls.
Quick start
Render a QR code in Blade, as an Svg object, as a data URI, or return it straight from a route as an image response.
Builder & options
The immutable PendingQr builder — error correction, versions, masks, segmentation, styling, the QrOptions form and option precedence.
Payloads
Typed payloads for text, links, e-mail, phone, SMS, Wi-Fi, vCard and geo — validated before a code is drawn.
Custom payloads
Implement the Payload contract for your own content — tickets, labels — with its own requirements and sensitivity.
2FA enrolment codes
Render an existing otpauth:// URI unchanged, or build TOTP/HOTP URIs — always treated as secrets.
SEPA credit transfer (EPC)
EPC069-12 v3.1 SEPA credit-transfer codes (GiroCode) — arguments, charsets, BIC rules and parsing scanned payloads.
PAY by square
Slovak PAY by square codes (spec 1.0.0–1.2.0) — payment orders, standing orders and direct debits, encode and decode.
Banking primitives
IBAN, BIC and ISO 11649 creditor-reference value objects — parse, validate, format and generate check digits.
Validation rules & cast
Form rules for IBAN, BIC, creditor references and QR capacity, plus an AsIban Eloquent cast.
SVG output & styling
One deterministic, accessible SVG path — module and finder styles, colours, responsive sizing and the Svg value object.
Responses & data URIs
Return codes as hardened image/svg+xml responses, force downloads, embed data URIs and img tags, and build a safe host route.
Blade component
Drop <x-qr-code> into any view — inline SVG or an img tag, with allow-listed attributes and no template compilation.
Sensitivity & caching
Public, Personal and Secret payloads — what gets memoised, cached and served cacheably, and how to override it.
Low-level encoder
Drive the ISO/IEC 18004 encoder directly — explicit segments, capacity, masks, and the QrMatrix and EncodingInfo objects.
Errors & translations
One exception hierarchy with stable reason keys, translatable user-facing messages, and the publishable translation file.
Artisan commands
Render SVG files or inspect a code’s version, level, mask and bit budget from the command line with qr:make.
Testing
Assert on real output — decode matrices with MatrixDecoder, check Qr::info() and Qr::fits(), and test response headers over HTTP.
Requirements
PHP 8.4+ with ext-mbstring and ext-bcmath, Laravel 12 or 13; ext-intl optional for payment-text normalisation.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.