当前位置:网站首页>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;
边栏推荐
- JS simple code determines whether the device that opens the page is the PC end of the computer, the H5 end of the mobile phone, or the wechat end
- [C language series] - detailed explanation of file operation (Part 1)
- Talking about Servlet
- Clickhouse learning (IX) Clickhouse integrating MySQL
- [C language series] - a recursive topic
- link与@import导入外部样式的区别
- On Paradigm
- ClickHouse学习(五)集群操作
- Relative positioning and absolute positioning
- QFrame类学习笔记
猜你喜欢

表格与表单相关知识点总结

eggjs 创建应用知识点

Basic concepts of MySQL + database system structure + extended application + basic command learning

HCIA-R&S自用笔记(27)综合实验

Detailed installation and use tutorial of MySQL (nanny installation with pictures and texts)

Qt布局管理--部件拉伸(Stretch)原理及大小策略(sizePolicy)

Longest string without duplicate characters

ClickHouse学习(三)表引擎

Qtcreator+cmake compiler settings
![[C language series] - constants and variables that confuse students](/img/24/1158034a5de413ea4ce160c5bfcbb4.png)
[C language series] - constants and variables that confuse students
随机推荐
Hcia-r & s self use notes (26) PPP
Do students in the science class really understand the future career planning?
个人学习笔记
字符类型转换
Qt设置背景图片方法
Display effect of uniapp page title
ClickHouse学习(十)监控运行指标
Qtcreator+cmake compiler settings
Global components component registration
相对定位和绝对定位
Question swiping Madness - leetcode's sword finger offer58 - ii Detailed explanation of left rotation string
Realize simple database query (incomplete)
Playwright实战案例之爬取js加密数据
Application of Huffman tree and Huffman coding in file compression
QT layout management -- Part stretch principle and sizepolicy
Detailed explanation of exit interrupt
使用Qss设置窗体样式
[C language series] - storage of deep anatomical data in memory (I) opening of summer vacation
公众号不支持markdown格式文件编写怎么办?
shell基本操作(下)