akira / laravel-qrcode
A clean, modern, and easy-to-use QR code generator for Laravel
Fund package maintenance!
kidiatoliny
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 1
Open Issues: 0
pkg:composer/akira/laravel-qrcode
Requires
- php: ^8.4
- ext-gd: *
- bacon/bacon-qr-code: ^3.0
- illuminate/contracts: ^12.0
- illuminate/support: ^12.0
Requires (Dev)
- akira/laravel-debugger: ^1.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: 4.0
- phpstan/phpstan: ^2.0
This package is auto-updated.
Last update: 2025-11-10 23:49:21 UTC
README
A clean, modern, and easy-to-use QR code generator for Laravel applications. Built with the Action Pattern, Value Objects, and full type safety.Features
- Multiple output formats (PNG, SVG, EPS)
- Highly customizable (colors, gradients, styles, sizes)
- Specialized data types (WiFi, Email, Phone, SMS, Geo, Bitcoin)
- Logo/image merging support
- Type-safe with PHP 8.4+
- PHPStan Level 9 compliant
- Comprehensive test coverage
Requirements
- PHP 8.4+
- Laravel 12.0+
Installation
Install via Composer:
composer require akira/laravel-qrcode
Optionally, publish the configuration:
php artisan vendor:publish --tag="qrcode-config"
Quick Start
use Akira\QrCode\Facades\QrCode; // Simple text $qrCode = QrCode::text('Hello World'); // With customization $qrCode = QrCode::size(300) ->color(255, 0, 0) ->text('https://example.com'); // WiFi network $qrCode = QrCode::wifi([ 'ssid' => 'MyNetwork', 'password' => 'secret123' ]); // Email $qrCode = QrCode::email('contact@example.com', 'Subject', 'Body'); // Phone $qrCode = QrCode::phone('+1234567890'); // With styling $qrCode = QrCode::size(400) ->gradient(255, 0, 0, 0, 0, 255, 'diagonal') ->style('round', 0.7) ->eye('circle') ->text('Styled QR Code');
Documentation
Complete documentation is available in the docs folder:
Getting Started
- Installation - Detailed installation guide
- Configuration - Configuration options
- Quick Start - Get started in 5 minutes
Usage Guide
- Basic Usage - Fundamentals and examples
- Data Types - WiFi, Email, Phone, SMS, Geo, Bitcoin
- Customization - Colors, gradients, styles
- Advanced Features - Logo merging, custom types
Examples & Reference
- Examples - Real-world use cases
- Architecture - Package design patterns
- API Reference - Complete method reference
- Testing - Testing guide
- Contributing - How to contribute
Available Data Types
| Type | Description | Example |
|---|---|---|
| WiFi | Network credentials | QrCode::wifi(['ssid' => 'Network', 'password' => 'pass']) |
| mailto links | QrCode::email('email@example.com', 'Subject', 'Body') |
|
| Phone | Direct dial | QrCode::phone('+1234567890') |
| SMS | Pre-filled message | QrCode::sms('+1234567890', 'Hello') |
| Geo | GPS coordinates | QrCode::geo(37.7749, -122.4194, 'San Francisco') |
| Bitcoin | Payment address | QrCode::bitcoin('address', 0.001, ['label' => 'Donation']) |
Customization Options
| Option | Description | Values |
|---|---|---|
| Size | Dimensions in pixels | size(300) |
| Colors | Foreground/background | color(r, g, b), backgroundColor(r, g, b) |
| Gradients | Color transitions | gradient(r1, g1, b1, r2, g2, b2, 'type') |
| Styles | Module shapes | style('square|dot|round', 0-1) |
| Eyes | Pattern styles | eye('square|circle'), eyeColor(...) |
| Error Correction | Data recovery | errorCorrection('L|M|Q|H') |
| Formats | Output type | format('png|svg|eps') |
| Logo | Image merging | merge('/path/to/logo.png', 0.2) |
Usage Examples
In Blade Templates
<img src="data:image/png;base64,{{ base64_encode($qrCode) }}" alt="QR Code">
API Response
return response()->json([ 'qrcode' => base64_encode(QrCode::format('png')->text($data)) ]);
Download Response
$png = QrCode::format('png')->size(500)->text($data); return response($png) ->header('Content-Type', 'image/png') ->header('Content-Disposition', 'attachment; filename="qrcode.png"');
With Logo
$qrCode = QrCode::format('png') ->size(400) ->errorCorrection('H') ->merge(public_path('logo.png'), 0.2) ->text('https://example.com');
Testing
# Run tests composer test # Run tests with coverage composer test-coverage # Run static analysis composer analyse # Run code style fixer composer lint
Architecture
This package is built with:
- Action Pattern - Single-responsibility business logic
- Value Objects - Immutable, validated data structures
- Dependency Injection - Laravel IoC container
- Type Safety - PHP 8.4+ with readonly classes
- SOLID Principles - Clean, maintainable code
See Architecture Documentation for details.
Contributing
Contributions are welcome! Please see Contributing Guide for details.
Security
If you discover any security issues, please email kidiatoliny@gmail.com instead of using the issue tracker.
Credits
- Kidiatoliny
- Built with BaconQrCode
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
