Giter Club home page Giter Club logo

qrcodeplus's Introduction

QrCodePlus

Build Status Style CI Downloads License

Feature

  • 基于QR Code 的一个二维码包
  • 可以生成四色, 九色, 十六色, 背景图二维码
  • 后续功能增加中...

四色二维码 九色二维码 图片二维码

Requirement

  1. PHP >= 7.1
  2. composer

Installation

composer require davidnineroc/qrcodeplus

Usage

基本使用: (九色)

<?php

require 'vendor/autoload.php';

use DavidNineRoc\Qrcode\Factory;
use DavidNineRoc\Qrcode\QrCodePlus;

/****************************************
 * 通过工厂方法,获取到你想创建二维码的样式
 * 现在仅有:color, image
 ****************************************/
$color = Factory::color(['#087', '#431', '#a2d', '#a2d',]);
// $image = Factory::image(imagecreatefrompng('DavidNineRoc.png'));


/****************************************
 * 实例化对象,并在 output 方法传入
 * $color 或者 $image
 ****************************************/
(new QrCodePlus)
    ->setText('DavidNineRoc')
    ->setMargin(50)
    ->setOutput(function($handle){
        header('Content-Type: image/jpeg');
        imagejpeg($handle);
    })
    ->output($color);

Documentation

  • MultipleColor Factory::color($hexColor = [], $alpha = 1)
    • 创建一个颜色实例
    • 参数一为十六进制颜色数组,颜色数量可为四,六,九
    • 参数二为透明度
  • ImageStyle Factory::($sourceImage = '', $alpha = 1)
    • 创建一个图片实例
    • 参数一为图片源,可为图片字符串和资源句柄
    • 参数二为透明度
  • QrCodePlus QrcodePlus::setText($text)
  • Qrcodeplus QrcodePlus::setOutput(Closure $closure)
    • 设置响应头输出,默认输出image/png
    • 可自行在中运行输出
    • 闭包只有一个参数那就是图片句柄,用于输出
  • void QrcodePlus::output(PlusInterface $qrcode)
    • 输出彩色二维码
    • 参数必须为 PlusInterface 实例
    • 也就是通过Factory::color()或者Factory::image()返回的实例
  • string QrcodePlus::getOutput(PlusInterface $qrcode)
    • 获取彩色二维码的输出,不直接显示

License

MIT

qrcodeplus's People

Contributors

seth-shi avatar

Watchers

James Cloos avatar loveqzhi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.