当前位置:网站首页>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;
边栏推荐
- OpenAtom OpenHarmony分论坛圆满举办,生态与产业发展迈向新征程
- 【无标题】
- 重绘与回流的关系
- Solve the problem that the prompt information of form verification does not disappear and the assignment does not take effect
- JS deep copy - Notes
- Qt布局管理--部件拉伸(Stretch)原理及大小策略(sizePolicy)
- link与@import导入外部样式的区别
- ClickHouse学习(二)ClickHouse单机安装
- 【TypeScript】深入学习TypeScript对象类型
- 微信小程序-屏幕高度
猜你喜欢
![[typescript] in depth study of typescript functions](/img/0c/e838960c8efd6e87046d35f8942a07.png)
[typescript] in depth study of typescript functions

table中同一列中合并相同项

Solve the problem that the prompt information of form verification does not disappear and the assignment does not take effect

Clickhouse learning (VIII) materialized view

ClickHouse学习(三)表引擎

DAY13:文件上传漏洞

HCIA-R&S自用笔记(25)NAT技术背景、NAT类型及配置

Masscan使用教程.

Cmu15-213 shell lab experiment record

DAY15:文件包含漏洞靶场手册(自用 file-include 靶场)
随机推荐
Clickhouse learning (VIII) materialized view
ClickHouse学习(七)表查询优化
Clickhouse learning (x) monitoring operation indicators
365 day challenge leetcode 1000 questions - day 035 one question per day + two point search 13
QFrame类学习笔记
Application of Huffman tree and Huffman coding in file compression
Detailed explanation of exit interrupt
uniapp组件之tab选项卡滑动切换
HCIA-R&S自用笔记(27)综合实验
Pyqt5: Chapter 1, Section 1: creating a user interface using QT components - Introduction
js简单代码判断打开页面的设备是电脑PC端或手机H5端或微信端
微信小程序更改属性值-setData-双向绑定-model
WIN10 编译ffmpeg(包含ffplay)
DAY13:文件上传漏洞
paddle. Fluid constant calculation error 'nonetype' object has no attribute 'get_ fetch_ list‘
Clickhouse learning (XI) clickhouseapi operation
How does the MD editor of CSDN input superscripts and subscripts? The input method of formula and non formula is different
DAY6:利用 PHP 编写登陆页面
HCIA-R&S自用笔记(26)PPP
常见特征工程操作