fmassei/qr-code 问题修复 & 功能扩展

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

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

fmassei/qr-code

Composer 安装命令:

composer require fmassei/qr-code

包简介

fmassei QR Code

README 文档

README

Latest Stable Version Build Status Total Downloads Monthly Downloads License

This library helps you create QR codes in SVG, PNG, and binary format.

  • Use the Imagick extension to render self-generated SVG images.
  • Logo and label placement
  • Can use of SVG frames
  • Common generation options
  • Matrix generated by bacon/bacon-qr-code
  • Simple internal structure

This library is based on the structure of endroid/qr-code, trying to overcome many deal-breaker characteristics present at the time of forking. Among the bigger changes:

  • Unified drawing (so results look the same in all formats)
  • Switch from GD to Imagick (for SVG support)
  • Switch from SimpleXMLElement to DOMDocument (more complex operations on SVG nodes)

Installation

Use Composer to install the library.

$ composer require fmassei/qr-code

Usage: generation and options

use fmassei\QrCode\QrCode;
use fmassei\QrCode\Logo;
use fmassei\QrCode\Label;
use fmassei\QrCode\Writer\PngWriter;

/* to create a code, make an instance of the QrCode class */
$qrCode = new QrCode("QR code data");

/* override some default settings */
$qrCode->size = 400;
$qrCode->foregroundColor = '#f00';
$qrCode->errorCorrectionLevel = QrCode::ERROR_CORRECTION_LEVEL_MEDIUM;

/* to set the optional logo and a label */
$qrCode->logo = Logo::fromPath(__DIR__.'/mylogo.png');
$qrCode->label = new Label("My first code!");

/* use a writer to generate the result */
$result = (new PngWriter())->write($qrCode);
        

Usage: working with results

/* Directly output the QR code */
header('Content-Type: '.$result->getMimeType());
echo $result->getString();

/* Save it to a file */
$result->saveToFile(__DIR__.'/qrcode.png');

/* Generate a data URI to include image data inline (i.e. inside an <img> tag) */
$dataUri = $result->getDataUri();

QR code example

One liner

Everyone expects it, I guess.

echo (new PngWriter())->write(new QrCode($myData))->getString();

SVG frames

A frame is a template for outputting code, logo and label. The library recognizes any element inside the SVG frame with id equals to:

  • SVGFrame::IDQrCode (default "QrCode"): this element will be subsituted with the QR code matrix
  • SVGFrame::IDLogo (default "Logo"): this element will be substituted with the passed Logo image (if any). No other variable of the Logo object is used.
  • SVGFrame::IDLabel (default "Label"): the value of this node will be substituted with the label text. No other variable of the Label object is used.

An example of the SVG structure and usage is available in the tests.

SVGFrame example

License

This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固