Skip to main content
The config/qrcode.php file is the central place to define default values that apply across every QR code your application generates through the facade, Blade component, or service container. Publishing it is optional — the package ships with sensible defaults — but it gives you full control without touching a single line of generation code.

Publish the config file

Run the following Artisan command to copy the config file into your application’s config/ directory:
After publishing, open config/qrcode.php and adjust the values to match your needs. Every QR code generated via the QrCode facade, the <x-qr-code> Blade component, or type-hinted Generator instances will automatically pick up these defaults.

Full config file

config/qrcode.php

Config options

string
default:"svg"
The image format used for every generated QR code.
The default changed from png to svg in v2.4.x. If you’re upgrading and rely on PNG output, set 'format' => 'png' (or QR_CODE_FORMAT=png in your .env).
integer
default:"400"
The width and height of the generated QR code, in pixels. Applies to raster formats (png, webp). For svg and eps this sets the viewBox dimensions.
integer
default:"4"
The quiet zone (blank border) around the QR code, measured in module units. QR code specifications require a minimum margin of 4 for reliable scanning. Reduce this only when embedding QR codes inside a pre-padded container.
string | array
default:"[0, 0, 0]"
The foreground (module) color of the QR code. Accepts any of the following formats:
The alpha channel uses a 0–100 scale (not the 0–127 scale used internally by PHP GD). The package scales the value automatically.
string | array
default:"[255, 255, 255]"
The background color of the QR code. Accepts the same formats as color.
string
default:"M"
The Reed-Solomon error correction level. Higher levels let scanners recover data from damaged or partially obscured codes, but increase the QR code’s visual density.
string
default:"UTF-8"
The character encoding applied to the data payload before it is encoded into the QR code. Change this only if you need to encode content in a non-Unicode encoding supported by the underlying bacon/bacon-qr-code library.
boolean
default:"false"
When true, the package skips Imagick entirely and uses PHP’s GD extension to render raster images (png, webp), even when Imagick is installed.Enable this when your server has Imagick installed but restricts its usage. Common restrictions include strict security policies such as ImageMagick security policy XML.
GD produces lower-quality raster output than Imagick and does not support all color operations. Leave this false unless you have a specific reason to bypass Imagick.

How defaults are applied

Config-driven defaults apply automatically when you use:
  • The QrCode facadeQrCode::generate(...)
  • The <x-qr-code> Blade component
  • Type-hinting Linkxtr\QrCode\Generator via Laravel’s service container
They do not apply when you instantiate the generator directly with new Generator() and omit the config array. In that case the package uses its hardcoded defaults.
Any method you chain on a per-call basis always overrides the config default for that call only. The config file is never mutated.