Skip to main content
Every method documented here returns a cloned Generator instance, keeping the original state intact. Chain as many calls as you need before calling generate() or any data-type method to produce your final QrCodeResult.

style()

public function style(string|Style $style, ?float $size = null): static
Set the shape used to draw each QR module (the individual dots that make up the code).
style
string
required
The module style. Accepted values:
ValueDescription
squareStandard filled squares (default)
dotCircular dots
roundSquares with rounded corners
size
float
Optional scaling factor for the module size, between 0.0 and 1.0. Useful with dot style to add spacing between dots. Defaults to the renderer’s built-in size.
QrCode::size(300)
    ->style('dot')
    ->generate('https://example.com');

eye()

public function eye(string|EyeStyle $style): static
Set the style of the three outer finder-pattern squares (the large corner squares that help scanners locate the code).
style
string
required
Accepted values:
ValueDescription
squareStandard square outline (default)
circleCircular outer ring
pointySquare with pointed inner corners
QrCode::size(300)
    ->eye('circle')
    ->generate('https://example.com');

internalEye()

public function internalEye(string|EyeStyle $style): static
Set the style of the three inner finder-pattern squares independently of the outer eye. Use this together with eye() to create composite eye designs.
style
string
required
Accepted values: square, circle, pointy — same as eye().
QrCode::size(300)
    ->eye('circle')
    ->internalEye('square')
    ->generate('https://example.com');

eyeColor()

public function eyeColor(int $eyeNumber, string|array $inner, string|array|null $outer = null): static
Override the color of a single finder-pattern eye. Call this method up to three times to style each eye independently.
Requires the ext-imagick PHP extension for raster output (PNG). The GD fallback does not support per-eye colors and will throw a MissingExtensionException if eyeColor() is used without Imagick. SVG and EPS output work without Imagick.
eyeNumber
int
required
The index of the eye to color. Accepted values: 0, 1, 2 (top-left, top-right, bottom-left respectively).
inner
string | array
required
Color for the inner square of the eye. Pass a hex string (e.g. '#e11d48') or an RGB array (e.g. [225, 29, 72]).
outer
string | array | null
Color for the outer ring of the eye. Accepts the same formats as inner. When null, the outer ring inherits the global foreground color set by color().
QrCode::size(300)
    ->eyeColor(0, '#1d4ed8', '#93c5fd') // eye 0: blue theme
    ->eyeColor(1, '#15803d', '#86efac') // eye 1: green theme
    ->eyeColor(2, '#b91c1c', '#fca5a5') // eye 2: red theme
    ->generate('https://example.com');

size()

public function size(int $size): static
Set the output image width and height in pixels. The QR code is always square.
size
int
required
Pixel dimensions for both width and height. The default from the package config is 400.
QrCode::size(250)->generate('https://example.com');

margin()

public function margin(int $margin): static
Set the quiet-zone margin — the blank border surrounding the QR code. A margin of at least 4 modules is recommended by the QR specification for reliable scanning.
margin
int
required
Margin thickness in pixels. The package default is 4.
QrCode::margin(6)->generate('https://example.com');

format()

public function format(string|Format $format): static
Set the output image format.
format
string
required
Accepted values:
ValueRequiresNotes
svgDefault. Vector format; no PHP extension required.
pngext-imagick or ext-gdRaster format. Falls back to GD if Imagick is unavailable.
webpext-imagickRaster format. Requires Imagick.
epsPostScript vector. Image merging is not supported for EPS.
QrCode::format('png')->size(400)->generate('https://example.com');

encoding()

public function encoding(string $encoding): static
Set the character encoding used when converting the text payload to QR code data. The default is UTF-8, which handles most use cases including multibyte characters.
encoding
string
required
Any valid PHP character encoding string, such as UTF-8, ISO-8859-1, or Shift_JIS.
QrCode::encoding('UTF-8')->generate('日本語テキスト');

errorCorrection()

public function errorCorrection(string|ErrorCorrectionLevel $errorCorrection): static
Set the Reed–Solomon error correction level. Higher correction means the QR code can recover from more physical damage or obstruction, but also produces a denser, larger code for the same payload.
errorCorrection
string
required
Accepted values:
LevelRecovery capacityTypical use
L~7%Maximum data density; minimal redundancy
M~15%Balanced default for most use cases
Q~25%Good choice when embedding a logo
H~30%Best durability; use for printed materials
Use H error correction when you overlay a logo using merge() or mergeString(). The extra redundancy ensures scanners can still read the code even though part of it is covered.
QrCode::size(400)
    ->errorCorrection('H')
    ->merge(public_path('logo.png'), 0.3)
    ->generate('https://example.com');

Full styling example

use Linkxtr\QrCode\Facades\QrCode;

$qr = QrCode::size(350)
    ->format('svg')
    ->margin(4)
    ->errorCorrection('Q')
    ->encoding('UTF-8')
    ->style('dot', 0.9)
    ->eye('circle')
    ->internalEye('square')
    ->color(15, 23, 42)
    ->backgroundColor(248, 250, 252)
    ->generate('https://example.com');

// Return as an HTTP response
return $qr;