qr:generate Artisan command lets you create QR codes directly from the terminal. It is ideal for build scripts, batch export pipelines, CI/CD workflows, and quick local tests — no PHP code required. The command supports two modes: interactive (guided prompts) and non-interactive (inline flags for scripting).
Interactive mode
Run the command with no arguments to start a guided session. Laravel Prompts walks you through each option — payload, output path, format, and advanced settings — with sensible defaults at every step:- Payload — what to encode (e.g. a URL or plain text)
- Output path — where to save the file (leave blank to print to the console)
- Format —
svg,png,webp, oreps(shown only when an output path is provided) - Advanced options — confirm whether to configure size, colors, margin, and error correction
If you have already passed any advanced flag (e.g.
--size), the
advanced-options prompt defaults to yes so you can fill in the remaining
fields interactively.Non-interactive mode
Pass the payload as a positional argument and use flags to set every option. This mode is designed for scripting — it skips all prompts and exits immediately with a success or failure code.--output, the raw QR code is printed directly to stdout. For SVG this is human-readable markup; for binary formats pipe the output to a file:
All available options
string
Positional argument. The payload to encode in the QR code. Omit it to
enter interactive mode.
string
File path to save the generated QR code (e.g.
public/qr.svg,
storage/app/exports/badge.png). If omitted, the output is printed to the
console.string
default:"svg"
Output format:
svg, png, webp, or eps. Unlike the Blade component, the
CLI supports all four formats including EPS for print workflows.int
default:"400"
Size of the QR code in pixels. Must be a positive integer.
string
default:"0,0,0"
Foreground color as comma-separated RGB or RGBA integers. RGB channels are
0–255; the optional alpha channel is 0–100. Examples: 255,0,0 (red),
0,102,204,80 (blue at 80 % opacity).string
default:"255,255,255"
Background color in the same
R,G,B or R,G,B,A format as --color.string
default:"M"
Error correction level:
L (7 %), M (15 %), Q (25 %), or H (30 %). Use
H when overlaying a logo to ensure the QR code remains scannable.int
default:"4"
Quiet-zone margin around the QR code. Must be zero or a positive integer.
Step-by-step: batch export
Use the command in a shell loop to generate QR codes for a list of URLs in one go:1
Create a URLs file
2
Run the loop
3
Verify the output
Use cases
Build scripts
Generate static QR code assets during your deployment pipeline so they are
always up to date without runtime generation overhead.
Batch export
Loop over a dataset and generate one QR code per record — product codes,
event tickets, asset tags — without writing a custom Artisan command.
CI/CD pipelines
Validate that QR generation works in your environment after every deploy by
running a quick smoke test command in your pipeline.
Local testing
Preview QR code output for any format or option combination instantly,
without spinning up a browser or writing throwaway PHP.
Exit codes
Scripts can check
$? immediately after the command to detect and handle failures: