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
Requires
- php: ^8.2
- ext-gd: *
- bacon/bacon-qr-code: ^2.0
- illuminate/contracts: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.0|^8.0
- orchestra/testbench: ^8.0|^9.0|^10.0
- pestphp/pest: ^2.0|^3.0
- pestphp/pest-plugin-laravel: ^2.0|^3.0
- phpstan/phpstan: ^1.10
README
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.