config/app.php at all — just require the package and start generating.
Require the package
Run the following command from your project root:Composer resolves the package and its only production dependency,
bacon/bacon-qr-code.Confirm auto-discovery (nothing to do)
Laravel automatically registers the service provider and the You should see
QrCode facade alias. You don’t need to edit config/app.php.To verify, run:Linkxtr\QrCode\QrCodeServiceProvider listed under Providers.If your application has disabled package auto-discovery, add the provider and alias manually in
config/app.php:Publish the config (optional)
If you want to set app-wide defaults — such as a different output format, a custom size, or a brand color — publish the config file:This creates
config/qrcode.php in your project:config/qrcode.php
Environment variable overrides
Every key in the config file reads from a corresponding environment variable, so you can change defaults per-environment without touching the published file:| Environment variable | Config key | Default |
|---|---|---|
QR_CODE_FORMAT | format | svg |
QR_CODE_SIZE | size | 400 |
QR_CODE_MARGIN | margin | 4 |
QR_CODE_COLOR | color | 0,0,0 |
QR_CODE_BACKGROUND_COLOR | background_color | 255,255,255 |
QR_CODE_ERROR_CORRECTION | error_correction | M |
QR_CODE_ENCODING | encoding | UTF-8 |
QR_CODE_FORCE_GD | force_gd | false |
Install ext-imagick for PNG/WebP (optional)
SVG and EPS output require no image extensions. For PNG and WebP, the package needs either To force GD even when Imagick is present, set
ext-imagick or ext-gd.Imagick (recommended)
Provides higher-quality raster output. Install via your system package manager:
GD (automatic fallback)
GD ships with most PHP distributions. If
ext-imagick is not detected, the package silently falls back to GD for PNG and WebP — no configuration needed.QR_CODE_FORCE_GD=true in your .env file or publish the config and set 'force_gd' => true.What’s installed
After completing the steps above, your application has:- The
QrCodefacade available globally - The
<x-qr-code>and<x-qrcode>Blade components registered - The
php artisan qr:generateArtisan command available - An optional
config/qrcode.phpwith app-wide defaults