定制 yellowskies/qr-code-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

yellowskies/qr-code-bundle

Composer 安装命令:

composer require yellowskies/qr-code-bundle

包简介

Symfony Barcode & QR Code Generator Bundle with Twig extension

README 文档

README

Latest Stable Version License

A Symfony Barcode & QR Code Generator Bundle with Twig extension.

Supports PHP 8.2+ and Symfony 6.4 / 7.x / 8.x

Features

  • Support 3 two-dimensional (2D) and 30 one-dimensional (1D) Barcode types
  • Three output formats: HTML, PNG and SVG
  • Twig integration: use the barcode function directly in your templates
  • No external dependencies for barcode generation

Installation

composer require yellowskies/qr-code-bundle

The bundle uses Symfony Flex and will be automatically configured.

Manual registration (if not using Flex)

Add to config/bundles.php:

return [
    // ...
    Skies\QRcodeBundle\SkiesQRcodeBundle::class => ['all' => true],
];

Usage

Generate options

Option Type Required Allowed values Description
code string required What you want to encode
type string required See types below Type of barcode
format string required html, svg, png Output format
width int optional Width of unit
height int optional Height of unit
color string/array optional HTML color / [R,G,B] Barcode color

Default width/height: 2D = 5x5, 1D = 2x30 Default color: html/svg = "black", png = [0, 0, 0]

In Twig templates

{# HTML barcode #}
{{ barcode({code: 'Hello World', type: 'qrcode', format: 'html'}) }}

{# SVG with custom size and color #}
{{ barcode({code: 'Hello World', type: 'qrcode', format: 'svg', width: 10, height: 10, color: 'green'}) }}

{# PNG (base64 encoded) #}
<img src="data:image/png;base64,{{ barcode({code: 'Hello World', type: 'datamatrix', format: 'png'}) }}" />

In a controller/service

use Skies\QRcodeBundle\Generator\Generator;

class MyController extends AbstractController
{
    public function index(Generator $generator): Response
    {
        $barcode = $generator->generate([
            'code'   => 'Hello World',
            'type'   => 'qrcode',
            'format' => 'svg',
            'width'  => 10,
            'height' => 10,
            'color'  => 'green',
        ]);

        return new Response($barcode);
    }
}

Standalone usage

use Skies\QRcodeBundle\Generator\Generator;

$generator = new Generator();
$barcode = $generator->generate([
    'code'   => 'Hello World',
    'type'   => 'qrcode',
    'format' => 'html',
]);

Save to file

// HTML or SVG
file_put_contents('/tmp/barcode.svg', $barcode);

// PNG (decode base64 first)
file_put_contents('/tmp/barcode.png', base64_decode($barcode));

Supported Barcode Types

2D Barcodes

Type Name Example
qrcode QR Code
pdf417 PDF417
datamatrix Data Matrix

1D Barcodes

Type Name
c128 Code 128
c128a/b/c Code 128 A/B/C
c39 Code 39
c39+ Code 39 with check digit
c39e Code 39 Extended
c39e+ Code 39 Extended with check digit
c93 Code 93
ean8 EAN-8
ean13 EAN-13
upca UPC-A
upce UPC-E
i25 Interleaved 2 of 5
s25 Standard 2 of 5
msi MSI
postnet POSTNET
planet PLANET
rms4cc RMS4CC
kix KIX-code
imb Intelligent Mail
codabar Codabar
code11 Code 11
pharma Pharmacode
pharma2t Pharmacode Two-Track

Requirements

  • PHP 8.2+
  • Symfony 6.4+ / 7.x / 8.x
  • GD extension (for PNG output)
  • bcmath extension (for Intelligent Mail barcodes)

Upgrade from 1.x

If upgrading from version 1.x:

  1. Update your composer.json to require "yellowskies/qr-code-bundle": "^2.0"
  2. Ensure you're running PHP 8.2+ and Symfony 6.4+
  3. The Twig function now returns the barcode string instead of echoing it (no change needed in templates)

License

Apache-2.0

yellowskies/qr-code-bundle 适用场景与选型建议

yellowskies/qr-code-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 707.93k 次下载、GitHub Stars 达 36, 最近一次更新时间为 2016 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「generator」 「twig」 「bundle」 「barcode」 「qr code」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yellowskies/qr-code-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yellowskies/qr-code-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 yellowskies/qr-code-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 707.93k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 37
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 36
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-09-29