akira/laravel-qrcode
Composer 安装命令:
composer require akira/laravel-qrcode
包简介
A clean, modern, and easy-to-use QR code generator for Laravel
README 文档
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, WebP, PDF)
- Highly customizable (colors, gradients, styles, sizes)
- Specialized data types (WiFi, Email, vCard, Calendar, Phone, SMS, Geo, Bitcoin, Ethereum, Litecoin)
- Logo/image merging support (from a file path or string content)
- Built-in cache-backed generation and batch generation
- Artisan command (
qrcode:generate) with CSV batch mode - Type-safe with PHP 8.4+
- PHPStan Level 9 compliant with 100% type coverage
- Comprehensive test coverage
Requirements
- PHP 8.4+
- GD extension
- Imagick extension for PNG, WebP, and PDF output
- 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'); // Contact card $qrCode = QrCode::vcard([ 'fullName' => 'Jane Doe', 'email' => 'jane@example.com' ]); // Calendar event $qrCode = QrCode::ical([ 'summary' => 'Release planning', 'startsAt' => '2026-06-01 10:00:00 UTC', 'endsAt' => '2026-06-01 11:00:00 UTC' ]); // Phone $qrCode = QrCode::phone('+1234567890'); // Ethereum $qrCode = QrCode::ethereum( '0x0000000000000000000000000000000000000001', '1000000000000000000' ); // Litecoin $qrCode = QrCode::litecoin('ltcaddress', 1.25); // 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
Browse the full documentation in docs/, or on the package website: https://packages.akira-io.com/packages/laravel-qrcode
Highlights: Installation - Configuration - Data Types - Customization - API Reference - Command Line
Available Data Types
| Type | Description | Example |
|---|---|---|
| WiFi | Network credentials | QrCode::wifi(['ssid' => 'Network', 'password' => 'pass']) |
| mailto links | QrCode::email('email@example.com', 'Subject', 'Body') |
|
| vCard | Contact cards | QrCode::vcard(['fullName' => 'Jane Doe']) |
| Calendar | VEVENT calendar entries | QrCode::ical(['summary' => 'Meeting', 'startsAt' => '2026-06-01 10:00:00 UTC', 'endsAt' => '2026-06-01 11:00:00 UTC']) |
| 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']) |
| Ethereum | Payment address | QrCode::ethereum('0x...', '1000000000000000000', ['chainId' => 1]) |
| Litecoin | Payment address | QrCode::litecoin('address', 1.25, ['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|webp|pdf') |
| Logo | Image merging | merge('/path/to/logo.png', 0.2) |
Usage Examples
In Blade Templates
{!! QrCode::format('png')->generate('https://example.com') !!}
API Response
return response()->json([ 'qrcode' => base64_encode(QrCode::format('png')->generateRaw($data)) ]);
Download Response
$png = QrCode::format('png')->size(500)->generateRaw($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 code quality checks and tests composer test # 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.
Links
akira/laravel-qrcode 适用场景与选型建议
akira/laravel-qrcode 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.47k 次下载、GitHub Stars 达 49, 最近一次更新时间为 2025 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「qrcode」 「laravel」 「qr」 「akira」 「bacon」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 akira/laravel-qrcode 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 akira/laravel-qrcode 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 akira/laravel-qrcode 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Based in http://phpqrcode.sourceforge.net/
Symfony 4, 5, 6 ,7 Barcode Generator Bundle with Twig function extension
Generates QR Codes
The jquery qrcode for yii2.
Symfony2 Barcode Generator Bundle with Twig function extension
统计信息
- 总下载量: 4.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 49
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-10
