> ## Documentation Index
> Fetch the complete documentation index at: https://docs.linkx.tr/llms.txt
> Use this file to discover all available pages before exploring further.

# Styling Methods — Shape, Format & Error Correction

> Control size, margin, module style, eye shapes, output format, character encoding, and error correction level for every QR code you generate.

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()

```php theme={null}
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:

| Value | Description |
| - | - |
| `square` | Standard filled squares (default) |
| `dot` | Circular dots |
| `round` | Squares 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.

```php Dot style theme={null}
QrCode::size(300)
    ->style('dot')
    ->generate('https://example.com');
```

```php Round style with custom module size theme={null}
QrCode::size(300)
    ->style('round', 0.8)
    ->generate('https://example.com');
```

***

## eye()

```php theme={null}
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:

| Value | Description |
| - | - |
| `square` | Standard square outline (default) |
| `circle` | Circular outer ring |
| `pointy` | Square with pointed inner corners |

```php theme={null}
QrCode::size(300)
    ->eye('circle')
    ->generate('https://example.com');
```

***

## internalEye()

```php theme={null}
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()`.

```php theme={null}
QrCode::size(300)
    ->eye('circle')
    ->internalEye('square')
    ->generate('https://example.com');
```

***

## eyeColor()

```php theme={null}
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.

> [!WARNING]
>
> 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()`.

```php Hex string colors theme={null}
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');
```

```php RGB array colors theme={null}
QrCode::size(300)
    ->eyeColor(0, [29, 78, 216], [147, 197, 253])
    ->generate('https://example.com');
```

```php Inner color only (outer inherits foreground) theme={null}
QrCode::size(300)
    ->color(0, 0, 0)
    ->eyeColor(0, '#e11d48') // outer stays black
    ->generate('https://example.com');
```

***

## size()

```php theme={null}
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`.

```php theme={null}
QrCode::size(250)->generate('https://example.com');
```

***

## margin()

```php theme={null}
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`.

```php theme={null}
QrCode::margin(6)->generate('https://example.com');
```

***

## format()

```php theme={null}
public function format(string|Format $format): static
```

Set the output image format.

**format** `string` *required*

Accepted values:

| Value | Requires | Notes |
| - | - | - |
| `svg` | — | Default. Vector format; no PHP extension required. |
| `png` | `ext-imagick` or `ext-gd` | Raster format. Falls back to GD if Imagick is unavailable. |
| `webp` | `ext-imagick` | Raster format. Requires Imagick. |
| `eps` | — | PostScript vector. Image merging is not supported for EPS. |

```php PNG theme={null}
QrCode::format('png')->size(400)->generate('https://example.com');
```

```php SVG (default) theme={null}
QrCode::format('svg')->generate('https://example.com');
```

```php WebP theme={null}
QrCode::format('webp')->size(400)->generate('https://example.com');
```

***

## encoding()

```php theme={null}
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`.

```php theme={null}
QrCode::encoding('UTF-8')->generate('日本語テキスト');
```

***

## errorCorrection()

```php theme={null}
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:

| Level | Recovery capacity | Typical 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 |

> [!TIP]
>
> 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.

```php High correction for logo overlay theme={null}
QrCode::size(400)
    ->errorCorrection('H')
    ->merge(public_path('logo.png'), 0.3)
    ->generate('https://example.com');
```

```php Low correction for high-density data theme={null}
QrCode::size(600)
    ->errorCorrection('L')
    ->generate(str_repeat('A', 400));
```

***

## cache()

```php theme={null}
public function cache(DateTimeInterface|DateInterval|int|null $ttl = null): static
```

Enable caching for the generated QR code using Laravel's cache store. When caching is enabled, the QR code is generated once and cached for the specified Time-To-Live (TTL). Subsequent requests for the same QR code load from the cache instantly.

**ttl** `DateTimeInterface | DateInterval | int | null`

The time-to-live for the cached QR code. Pass an integer (seconds), a `DateInterval` instance, a `DateTimeInterface` expiration time, or `null` to use the default cache TTL configured in `config/qrcode.php` (default: `1440` minutes / 24 hours).

```php theme={null}
use Linkxtr\QrCode\Facades\QrCode;

// Cache with default TTL (1440 minutes / 24 hours)
$qr = QrCode::cache()->generate("https://example.com");

// Cache with custom TTL (e.g., 3600 seconds / 1 hour)
$qr = QrCode::cache(3600)->generate("https://example.com");
```

***

## withoutCache()

```php theme={null}
public function withoutCache(): static
```

Explicitly disable caching for the current generator instance, overriding any package-wide caching enabled in `config/qrcode.php`.

```php theme={null}
use Linkxtr\QrCode\Facades\QrCode;

// Bypasses cache even if cache_enabled is true in config
$qr = QrCode::withoutCache()->generate("https://example.com");
```

***

## Full styling example

```php theme={null}
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;
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.