roundly-consulting / qr-for-laravel
Native QR codes for Laravel: an ISO/IEC 18004 encoder with optimal segmentation, one optimised SVG renderer, and typed payloads for otpauth 2FA, EPC SEPA transfers and PAY by square — zero third-party dependencies.
Package info
github.com/roundly-consulting/qr-for-laravel
pkg:composer/roundly-consulting/qr-for-laravel
Fund package maintenance!
Requires
- php: ^8.4
- ext-bcmath: *
- ext-mbstring: *
- illuminate/console: ^12.0|^13.0
- illuminate/contracts: ^12.0|^13.0
- illuminate/database: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- illuminate/view: ^12.0|^13.0
- roundly-consulting/crypto-for-laravel: ^1.0
- roundly-consulting/enums-for-laravel: ^1.0
- roundly-consulting/money-for-laravel: ^1.0
- roundly-consulting/package-toolkit-for-laravel: ^1.0
Requires (Dev)
- ext-dom: *
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- nunomaduro/collision: ^8.5
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- roundly-consulting/testing-for-laravel: ^1.0
Suggests
- ext-intl: NFC-normalises payment text (EPC/PAY by square) before length checks via \Normalizer; without it text is encoded exactly as given.
Provides
None
Conflicts
None
Replaces
None
README
QR for Laravel
Native QR codes for Laravel: an ISO/IEC 18004 encoder, one optimised SVG renderer, and typed payloads for 2FA setup codes, links, contacts, Wi-Fi, SEPA credit transfers (EPC069-12) and Slovak PAY by square payments. No third-party runtime libraries.
Installation
Requires PHP 8.4 (ext-mbstring, ext-bcmath) and Laravel 12 or 13.
composer require roundly-consulting/qr-for-laravel
Usage
Build a code fluently and render it as SVG — or return the builder from a route:
use RoundlyConsulting\Qr\Facades\Qr; $svg = Qr::url('https://example.com/menu/12') ->size(240) ->errorCorrection('Q') ->title('Scan to order') ->svg(); // Svg value object, Htmlable $svg->toString(); // the <svg> markup Qr::url('https://example.com')->toDataUri(); // data:image/svg+xml;charset=utf-8,… Route::get('/tables/{table}/qr', fn (Table $table) => Qr::url(route('menu', $table))); // image/svg+xml
Payments and 2FA enrolment codes are typed payloads too:
use RoundlyConsulting\Money\Money; use RoundlyConsulting\Qr\Payloads\Payments\Epc\EpcPayment; $payment = new EpcPayment( name: 'VetClinic s.r.o.', iban: 'SK96 1100 0000 0029 1859 9669', amount: Money::ofMinor(12550, 'EUR'), reference: 'RF18539007547034', ); Qr::epc($payment)->svg(); Qr::otpauth($setup->provisioningUri)->svg(); // never cached, served with no-store
Or drop one into a view:
<x-qr-code :data="$payment" :size="200" title="Scan to pay" />
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/qr-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
The MIT License (MIT). See LICENSE.md.