devoton/qrcode

Open-source Laravel QR code generator with a native PHP engine for SVG, PNG and data URI output.

Maintainers

Package info

github.com/otontraore/qrcode

Documentation

pkg:composer/devoton/qrcode

Statistics

Installs: 20

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

0.1.0 2026-04-16 12:06 UTC

This package is auto-updated.

Last update: 2026-04-19 12:32:33 UTC


README

Laravel package for generating QR codes with a native PHP engine.

It supports SVG, PNG, data URI output, a fluent builder, and Laravel container or facade usage.

Repository: https://github.com/otontraore/qrcode

Requirements

  • PHP ^8.2
  • Laravel ^11.0|^12.0
  • GD extension for PNG output

Installation

composer require devoton/qrcode

Publish the config if you want to override defaults:

php artisan vendor:publish --tag=devoton-qrcode-config

Quick start

use DevOton\QrCode\Contracts\QrCodeGeneratorInterface;

$generator = app(QrCodeGeneratorInterface::class);

$svg = $generator->svg('https://example.com');

Using the facade:

use DevOton\QrCode\Facades\DevOtonQrCode;

$png = DevOtonQrCode::png('https://example.com', [
    'size' => 180,
    'margin' => 2,
    'foreground' => '#111827',
    'background' => '#ffffff',
    'error_correction' => 'medium',
]);

Using the fluent builder:

use DevOton\QrCode\Contracts\QrCodeGeneratorInterface;

$svg = app(QrCodeGeneratorInterface::class)
    ->make('https://example.com')
    ->size(220)
    ->margin(3)
    ->foreground('#0f172a')
    ->background('#ffffff')
    ->errorCorrection('quartile')
    ->encoding('UTF-8')
    ->asSvg();

Output methods

$svg = $generator->svg('https://example.com', 160, 2);

$png = $generator->png('https://example.com', [
    'size' => 160,
    'margin' => 2,
]);

$dataUri = $generator->dataUri('https://example.com', [
    'format' => 'svg',
]);

$generator->save('https://example.com', storage_path('app/qrcode.svg'));

Options

Option Type Notes
size int Final size in pixels. Must be greater than 0.
margin int Quiet zone in modules. Must be 0 or more.
encoding string Input encoding, for example UTF-8 or ISO-8859-1.
error_correction string low, medium, quartile, or high.
foreground string Foreground color as a 6-digit hex value.
background string Background color as a 6-digit hex value.
format string svg or png. Used by dataUri() and save().

Configuration

Published file: config/devoton-qrcode.php

Defaults inside the package:

return [
    'default_size' => 150,
    'default_margin' => 1,
    'encoding' => 'UTF-8',
    'default_error_correction' => 'low',
    'default_foreground' => '#000000',
    'default_background' => '#ffffff',
];

Notes

  • PNG rendering requires the PHP GD extension.
  • The current engine focuses on byte mode.
  • Colors currently accept 6-digit hexadecimal values.

Development

Run formatting and the package test suite before a release or pull request:

vendor/bin/pint --dirty --format agent
php artisan test --compact packages/devoton/qrcode/tests/Feature/DevOtonQrCodePackageTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeNativeFoundationTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeNativePipelineTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeConformanceTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeCodewordSnapshotTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeIntermediateSnapshotTest.php

See CHANGELOG.md for release history and RELEASE.md for the release checklist.