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’sconfig/ directory:
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
The image format used for every generated QR code.
| Value | Description |
|---|---|
svg | Scalable vector graphic. No image extension required. Renders crisply at any size. |
png | Raster PNG — requires GD or Imagick |
webp | Modern raster format — requires GD or Imagick |
eps | Encapsulated PostScript vector format for print workflows |
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).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.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.
The foreground (module) color of the QR code. Accepts any of the following formats:
| Format | Example |
|---|---|
| RGB CSV string | "0,0,0" |
| RGBA CSV string (alpha 0–100) | "0,0,0,100" |
| RGB array | [0, 0, 0] |
| RGBA array (alpha 0–100) | [0, 0, 0, 100] |
| Hex string | "#000000" |
The alpha channel uses a 0–100 scale (not the 0–127 scale used internally by PHP GD). The package scales the value automatically.
The background color of the QR code. Accepts the same formats as
color.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.
| Level | Data recovery | Recommended use |
|---|---|---|
L | ~7 % | Clean digital displays |
M | ~15 % | General purpose (default) |
Q | ~25 % | Printed materials |
H | ~30 % | Codes with an embedded logo |
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.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.How defaults are applied
Config-driven defaults apply automatically when you use:
- The
QrCodefacade —QrCode::generate(...) - The
<x-qr-code>Blade component - Type-hinting
Linkxtr\QrCode\Generatorvia Laravel’s service container
new Generator() and omit the config array. In that case the package uses its hardcoded defaults.