devoton/qrcode 问题修复 & 功能扩展

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

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

devoton/qrcode

Composer 安装命令:

composer require devoton/qrcode

包简介

Open-source Laravel QR code generator with a native PHP engine for SVG, PNG and data URI output.

README 文档

README

Laravel package for generating QR codes with a native PHP engine.

It supports SVG, PNG, data URI output, a fluent builder, and Laravel container or facade usage.

Repository: https://github.com/otontraore/qrcode

Requirements

  • PHP ^8.2
  • Laravel ^11.0|^12.0
  • GD extension for PNG output

Installation

composer require devoton/qrcode

Publish the config if you want to override defaults:

php artisan vendor:publish --tag=devoton-qrcode-config

Quick start

use DevOton\QrCode\Contracts\QrCodeGeneratorInterface;

$generator = app(QrCodeGeneratorInterface::class);

$svg = $generator->svg('https://example.com');

Using the facade:

use DevOton\QrCode\Facades\DevOtonQrCode;

$png = DevOtonQrCode::png('https://example.com', [
    'size' => 180,
    'margin' => 2,
    'foreground' => '#111827',
    'background' => '#ffffff',
    'error_correction' => 'medium',
]);

Using the fluent builder:

use DevOton\QrCode\Contracts\QrCodeGeneratorInterface;

$svg = app(QrCodeGeneratorInterface::class)
    ->make('https://example.com')
    ->size(220)
    ->margin(3)
    ->foreground('#0f172a')
    ->background('#ffffff')
    ->errorCorrection('quartile')
    ->encoding('UTF-8')
    ->asSvg();

Output methods

$svg = $generator->svg('https://example.com', 160, 2);

$png = $generator->png('https://example.com', [
    'size' => 160,
    'margin' => 2,
]);

$dataUri = $generator->dataUri('https://example.com', [
    'format' => 'svg',
]);

$generator->save('https://example.com', storage_path('app/qrcode.svg'));

Options

Option Type Notes
size int Final size in pixels. Must be greater than 0.
margin int Quiet zone in modules. Must be 0 or more.
encoding string Input encoding, for example UTF-8 or ISO-8859-1.
error_correction string low, medium, quartile, or high.
foreground string Foreground color as a 6-digit hex value.
background string Background color as a 6-digit hex value.
format string svg or png. Used by dataUri() and save().

Configuration

Published file: config/devoton-qrcode.php

Defaults inside the package:

return [
    'default_size' => 150,
    'default_margin' => 1,
    'encoding' => 'UTF-8',
    'default_error_correction' => 'low',
    'default_foreground' => '#000000',
    'default_background' => '#ffffff',
];

Notes

  • PNG rendering requires the PHP GD extension.
  • The current engine focuses on byte mode.
  • Colors currently accept 6-digit hexadecimal values.

Development

Run formatting and the package test suite before a release or pull request:

vendor/bin/pint --dirty --format agent
php artisan test --compact packages/devoton/qrcode/tests/Feature/DevOtonQrCodePackageTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeNativeFoundationTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeNativePipelineTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeConformanceTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeCodewordSnapshotTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeIntermediateSnapshotTest.php

See CHANGELOG.md for release history and RELEASE.md for the release checklist.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固