当前位置:网站首页>PHP如何生成二维码?
PHP如何生成二维码?
2022-07-29 05:19:00 【廖圣平】
composer require endroid/qr-code
$label 为二维码说明文字,在二维码下方
该库可帮助您快速生成 QR 码。使用 bacon/bacon-qr-code 生成矩阵,使用 khanamiryan/qrcode-detector-decoder 验证生成的二维码。进一步扩展了 Twig 扩展、生成路线、工厂和 Symfony 捆绑包,以便于安装和配置。提供了不同的编写器来生成 PNG、SVG、EPS 或二进制格式的 QR 码。
$code = input('code');
$writer = new PngWriter();
$qrCode = QrCode::create($code)
->setEncoding(new Encoding('UTF-8'))
->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
->setSize(500)
->setMargin(10)
->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
->setForegroundColor(new Color(0, 0, 0))
->setBackgroundColor(new Color(255, 255, 255));
$label = Label::create($code)
->setMargin(new Margin(20, 0, 20, 0))
->setTextColor(new Color(0, 0, 0));
$result = $writer->write($qrCode, null, $label);
$content = $result->getString();
$res = Response::create($content,Image::class);
return $res;
边栏推荐
猜你喜欢
随机推荐
Hcia-r & s self use notes (26) PPP
nmap是什么以及使用教程
Character type conversion
Clickhouse learning (VI) grammar optimization
[C language series] - constants and variables that confuse students
字符类型转换
Wechat applet - component parameter transmission, state management
[C language series] - storage of deep anatomical data in memory (I) opening of summer vacation
Database operation day 6
用threejs 技术做游戏跑酷
365 day challenge leetcode1000 question - day 036 binary tree pruning + subarray and sorted interval sum + delete the shortest subarray to order the remaining arrays
微信小程序更改属性值-setData-双向绑定-model
相对定位和绝对定位
DAY14:Upload-labs 通关教程
Clickhouse learning (VII) table query optimization
HCIA-R&S自用笔记(27)综合实验
Detailed explanation of typical application code of C language array - master enters by mistake (step-by-step code explanation)
用sql-client.sh生成的job在cancle过后 如何实现断点续传?
[typescript] in depth study of typescript functions
Common characteristic engineering operations









