linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/linkxtr/laravel-qrcode

v1.0.0 2025-10-06 07:01 UTC

This package is auto-updated.

Last update: 2025-10-06 07:09:31 UTC


README

Latest Version on Packagist GitHub Tests Action Status Compatibility Test Total Downloads License

A clean, modern, and easy-to-use QR code generator for Laravel applications. This package provides a simple and intuitive API for generating QR codes in various formats with support for Laravel 10, 11, and 12, built on top of the reliable Bacon/BaconQrCode library.

๐Ÿš€ Simple QrCode Compatibility

This package is designed to be a drop-in replacement for simplesoftwareio/simple-qrcode with the following benefits:

  • โœ… Fully compatible with existing Simple QrCode method signatures
  • ๐Ÿš€ Faster performance with modern PHP 8.2+ optimizations
  • ๐Ÿ›  Strict type safety with PHP 8.2+ features
  • ๐Ÿ“ฆ Smaller footprint with minimal dependencies

Migration Guide

If you're migrating from simplesoftwareio/simple-qrcode, simply replace the namespace in your code:

- use SimpleSoftwareIO\QrCode\Facades\QrCode;
+ use Linkxtr\QrCode\Facades\QrCode;

All your existing QR code generation code should work without any changes. We maintain compatibility with all the commonly used methods from Simple QrCode.

Features

  • ๐Ÿ”ฅ Modern PHP 8.2+ with strict types and modern syntax
  • ๐ŸŽจ Multiple output formats: PNG, SVG, EPS, and more
  • ๐Ÿ–Œ๏ธ Customizable appearance: Colors, size, margins, and more
  • ๐Ÿ”„ Built-in caching for improved performance
  • ๐Ÿ”’ Support for different encodings: UTF-8, ISO-8859-1, etc.
  • ๐Ÿ“ฑ Responsive by default with SVG output
  • ๐Ÿงช 100% test coverage with Pest PHP
  • ๐Ÿ“ฆ Laravel 10, 11 & 12 compatibility
  • ๐Ÿ” IDE-friendly with proper type hints
  • ๐Ÿ”„ Simple QrCode compatible - Drop-in replacement for simplesoftwareio/simple-qrcode
  • ๐Ÿš€ Continuous compatibility testing to ensure ongoing compatibility with Simple QrCode

Requirements

  • PHP 8.2 or higher
  • Laravel 10, 11, or 12
  • GD Library or Imagick extension for image manipulation

Installation

You can install the package via Composer. This will automatically install the required bacon/bacon-qr-code package:

composer require linkxtr/laravel-qrcode

Basic Usage

Generating QR Codes

use Linkxtr\QrCode\Facades\QrCode;

// Generate a simple QR code
$qrCode = QrCode::generate('https://example.com');

// Generate QR code with custom size and margin
$qrCode = QrCode::size(300)
    ->margin(10)
    ->generate('https://example.com');

Available Methods

// Set QR code size (in pixels)
QrCode::size(250);

// Set QR code margin (in pixels)
QrCode::margin(10);

// Set foreground color
QrCode::color(255, 0, 0); // RGB

// Set background color
QrCode::backgroundColor(255, 255, 255, 0); // RGB with alpha

// Set error correction level (L, M, Q, H)
QrCode::errorCorrection('H');

// Set encoding
QrCode::encoding('UTF-8');

// Generate a data URL
$dataUrl = QrCode::format('png')->generate('https://example.com');

Blade Directive

<!-- Generate QR code in a view -->
<div class="qr-code">
    {!! QrCode::size(200)->generate('https://example.com') !!}
</div>

Advanced Usage

Custom Logo Overlay

$qrCode = QrCode::format('png')
    ->size(300)
    ->merge(public_path('logo.png'), 0.3, true)
    ->generate('https://example.com');

Response in Controller

use Linkxtr\QrCode\Facades\QrCode;
use Illuminate\Support\Facades\Response;

public function qrCode()
{
    $png = QrCode::format('png')
        ->size(200)
        ->generate('QR Code with custom data');
        
    return response($png)->header('Content-type', 'image/png');
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email security@your-email.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.