NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
QR for Laravel

Responses & data URIs

Return a builder or an Svg from a controller and it becomes an image response; the same object also yields data URIs and img tags:

return Qr::url($link);                                   // inline image/svg+xml
return Qr::url($link)->svg()->download('table-12.svg');  // attachment

return response()->json(['qr' => Qr::url($link)->toDataUri()]);
$base64 = Qr::url($link)->toDataUri(DataUriEncoding::Base64);
$img = Qr::url($link)->svg()->toImgTag('Scan me', ['class' => 'w-32']);
$svg = Qr::url($link)->svg()->withAttributes(['class' => 'qr', 'aria-hidden' => 'true']);
$etag = $svg->etag();

Response headers

HeaderPublicPersonalSecret
Content-Typeimage/svg+xml; charset=utf-8samesame
Cache-Controlpublic, max-age=… (+ immutable)private, max-age=…no-store, max-age=0
ETag / 304yesyesno (Pragma: no-cache)
X-Content-Type-Optionsnosniffnosniffnosniff
Content-Security-Policydefault-src 'none'; style-src 'unsafe-inline'samesame
Content-Dispositioninline; filename=qr-code.svg (attachment for download())samesame

Response bodies always carry the XML declaration. Download filenames are sanitised with an ASCII fallback. max-age comes from response.max_age, and immutable is appended when response.immutable is true.

A host route for user input

The package ships no routes. A host route that renders user input should authenticate, throttle and validate:

use RoundlyConsulting\Qr\Rules\FitsInQrCode;

Route::middleware(['auth', 'throttle:30,1'])->get('/qr', function (Request $request) {
    $data = $request->validate(['text' => ['required', 'string', new FitsInQrCode]]);

    return Qr::text($data['text']);
});

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 crypto

By 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.