定制 bitandblack/qr-code 二次开发

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

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

bitandblack/qr-code

最新稳定版本:1.2.0

Composer 安装命令:

composer require bitandblack/qr-code

包简介

Generates QR Codes

README 文档

README

PHP from Packagist Latest Stable Version Total Downloads License

Bit&Black QR Code

This library generates QR codes. It's based on endroid/qr-code by Jeroen van den Enden but differs by using bitandblack/colors to allow different color spaces.

Installation

This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/qr-code.

Usage

<?php 

use BitAndBlack\QrCode\QrCode;

$qrCode = new QrCode('Hello World!');

header('Content-Type: ' . $qrCode->getContentType());

echo $qrCode->writeString();

Advanced usage

<?php 

use Color\Value\RGB;
use BitAndBlack\QrCode\ErrorCorrectionLevel;
use BitAndBlack\QrCode\LabelAlignment;
use BitAndBlack\QrCode\QrCode;
use BitAndBlack\QrCode\Response\QrCodeResponse;

$qrCode = new QrCode('Hello World!');
$qrCode
    ->setSize(300)    
    ->setWriterByName('png')    
    ->setMargin(10)    
    ->setEncoding('UTF-8')    
    ->setErrorCorrectionLevel(
        new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH())
    )    
    ->setForegroundColor(
        new RGB(0, 0, 0)
    )    
    ->setBackgroundColor(
        new RGB(255, 255, 255)
    )    
    ->setLabel('Scan the code', 16, 'SomeFont.otf', LabelAlignment::CENTER)    
    ->setLogoPath('SomeLogo.png')    
    ->setLogoSize(150, 200)    
    ->setRoundBlockSize(true)    
    ->setValidateResult(false)    
    ->setWriterOptions([
        'exclude_xml_declaration' => true
    ])
;

// Directly output the QR code
header('Content-Type: ' . $qrCode->getContentType());

echo $qrCode->writeString();

// Save it to a file
$qrCode->writeFile(__DIR__ . '/qrcode.png');

// Create a response object
$response = new QrCodeResponse($qrCode);

Help

If you have any questions, feel free to contact us under hello@bitandblack.com.

Further information about Bit&Black can be found under www.bitandblack.com.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-29