yii生成二维码新版

2020-04-02 10:10:09

首先需要安装qrcode最新 yii插件:

php composer.phar require 2amigos/qrcode-library:~1.1

调用方式:

use Da\QrCode\QrCode;

$qrCode = (new QrCode(‘This is my text’))

->setSize(250)
->setMargin(5)
->useForegroundColor(51, 153, 255);

// now we can display the qrcode in many ways // saving the result to a file:

$qrCode->writeFile(DIR . ‘/code.png’); // writer defaults to PNG when none is specified

// display directly to the browser header(‘Content-Type: ‘.\(qrCode->getContentType()); echo \)qrCode->writeString();


文档地址:

https://qrcode-library.readthedocs.io/en/latest/