config/qrcode.php reads from a corresponding environment variable, so you can control package-wide defaults through your .env file without publishing or editing any PHP config. This is ideal for twelve-factor apps, containerized deployments, and multi-environment setups where each environment needs different QR code settings.
All supported environment variables
Add any of the following entries to your.env file. Omitting a variable leaves the built-in default in effect.
.env
Variable reference
string
default:"svg"
Sets the default image format for every generated QR code.
integer
default:"400"
Sets the default pixel dimensions of the generated QR code. For
svg and eps this controls the viewBox size; for png and webp it sets the actual pixel dimensions.integer
default:"4"
Sets the default quiet zone (blank border) around the QR code in module units. The QR code specification recommends a minimum of 4 for reliable scanning.
string
default:"0,0,0"
Sets the default foreground (module) color. Three formats are accepted:
string
default:"255,255,255"
Sets the default background color. Accepts the same three formats as
QR_CODE_COLOR.string
default:"M"
Sets the default Reed-Solomon error correction level.
string
default:"UTF-8"
Sets the default character encoding applied to the data payload before it is encoded. Only change this if you need a specific non-Unicode encoding supported by the underlying
bacon/bacon-qr-code library.boolean
default:"false"
When set to
true, the package skips Imagick and renders raster images using PHP’s GD extension, even when Imagick is available. Use this when your server installs Imagick but restricts it via security policies.Environment-specific examples
Use different defaults for local development vs. production without changing any PHP code:Color format reference
Environment variables are read by
config/qrcode.php at boot time. You do
not need to publish the config file to use env vars. The unpublished config
that ships with the package already calls env('QR_CODE_*', ...) for every
option. Publishing the config only adds the ability to set PHP array values
(such as [R, G, B]) directly in PHP, which is not possible in a .env file.