akira/laravel-qrcode 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

akira/laravel-qrcode

最新稳定版本:1.0.3

Composer 安装命令:

composer require akira/laravel-qrcode

包简介

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

README 文档

README

img.png

Latest Version on Packagist Tests PHPStan Total Downloads

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 package website: https://packages.akira-io.com/packages/laravel-qrcode

Available Data Types

Type Description Example
WiFi Network credentials QrCode::wifi(['ssid' => 'Network', 'password' => 'pass'])
Email 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

License

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

Links

统计信息

  • 总下载量: 58
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 39
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 39
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-10