承接 globus-studio/phpqrcode 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

globus-studio/phpqrcode

Composer 安装命令:

composer require globus-studio/phpqrcode

包简介

Zero-dependency QR Code generator for PHP 7.4-9.0. Dead simple API, full spec compliance, 100% test coverage.

README 文档

README

Zero-dependency QR Code generator for PHP 7.4–9.0.

CI PHP License

Features

  • Dead simple API - one line to generate QR
  • Zero runtime dependencies
  • PHP 7.4 / 8.0 / 8.1 / 8.2 / 8.3 / 8.4 / 8.5 / 9.0
  • QR Code versions 1–40, all error correction levels
  • Multiple output formats: SVG, PNG, HTML, ASCII, raw matrix
  • ~100% test coverage (186 tests, 2209 assertions)
  • PHPStan level max, zero errors
  • 17x faster with fixed mask pattern
  • PSR-4 autoloading

Requirements

  • PHP >= 7.4
  • ext-gd (optional, only for PNG rendering)

Installation

composer require globus-studio/phpqrcode

Usage

use GlobusStudio\QRCode\QRCode;

// SVG string
$svg = QRCode::svg('https://example.com');

// PNG as data URI (requires ext-gd)
$png = QRCode::png('https://example.com');

// HTML table
$html = QRCode::html('https://example.com');

// ASCII art
echo QRCode::string('https://example.com');

// Raw boolean matrix
$matrix = QRCode::matrix('https://example.com');

Options

use GlobusStudio\QRCode\QRCode;
use GlobusStudio\QRCode\ErrorCorrection\ErrorCorrectionLevel;

$svg = QRCode::svg('data', [
    'level' => ErrorCorrectionLevel::H,
    'size' => 4,
    'margin' => 2,
    'mask' => 3,            // fixed mask 0-7 (skips auto-selection, 17x faster)
    'foreground' => '#000000',
    'background' => '#ffffff',
]);

Performance

By default the encoder tests all 8 mask patterns to find the optimal one. For batch generation or when speed matters, pass a fixed mask (0–7):

// ~180ms per QR (auto mask selection)
$svg = QRCode::svg($data);

// ~11ms per QR (fixed mask, 17x faster)
$svg = QRCode::svg($data, ['mask' => 0]);

Object API

use GlobusStudio\QRCode\QRCode;
use GlobusStudio\QRCode\ErrorCorrection\ErrorCorrectionLevel;
use GlobusStudio\QRCode\Renderer\SvgRenderer;

$qr = new QRCode('https://example.com', ErrorCorrectionLevel::H);
$svg = $qr->render(new SvgRenderer(['size' => 6]));
$matrix = $qr->getMatrix();

Error Correction Levels

Level Recovery
L ~7%
M ~15%
Q ~25%
H ~30%

Renderers

Renderer Dependencies Output
SvgRenderer none SVG XML string
HtmlRenderer none HTML table
StringRenderer none ASCII/UTF-8
PngRenderer ext-gd PNG binary
RawRenderer none JSON / int[][]

Credits

Inspired by the original QRCode for PHP by Kazuhiko Arase (2009). Rewritten from scratch with modern PHP practices, strict typing, full test coverage, and zero deprecations.

License

MIT - see LICENSE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固