当前位置:网站首页>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;
边栏推荐
- 组件传参与生命周期
- QT setting background image method
- ·Let's introduce ourselves to the way of programming·
- paddle. Fluid constant calculation error 'nonetype' object has no attribute 'get_ fetch_ list‘
- ClickHouse学习(四)SQL操作
- Basic concepts of MySQL + database system structure + extended application + basic command learning
- Dynamic sorting of DOM object element blocks in applets
- Set the background color of a cell in the table
- js简单代码判断打开页面的设备是电脑PC端或手机H5端或微信端
- HCIA-R&S自用笔记(25)NAT技术背景、NAT类型及配置
猜你喜欢

Day 5

解决表单校验提示信息不消失问题以及赋值不生效问题

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

Introduction to C language array to proficiency (array elaboration)
![[C language series] - detailed explanation of file operation (Part 1)](/img/12/2d47fde0385d3f1dcb31f5efa82f7b.png)
[C language series] - detailed explanation of file operation (Part 1)
![[electronic circuit] how to select ADC chip](/img/41/05153704986117ce9adaa09cb71a7a.png)
[electronic circuit] how to select ADC chip

【TypeScript】深入学习TypeScript对象类型

ClickHouse学习(八)物化视图

使用Qss设置窗体样式

sql-server 数据表的简单操作
随机推荐
Basic use of redis
AR虚拟增强与现实
Longest string without duplicate characters
Flask 报错 RuntimeError: The session is unavailable because no secret key was set.
Clickhouse learning (V) cluster operation
相对定位和绝对定位
ClickHouse学习(十一)clickhouseAPI操作
[C language series] - three methods to simulate the implementation of strlen library functions
Do students in the science class really understand the future career planning?
On Paradigm
Related knowledge of elastic box
个人学习笔记
rem与px与em异同点
使用Qss设置窗体样式
Fvuln-自动化web漏洞检测工具
Provincial and urban three-level linkage (simple and perfect)
QT layout management -- Part stretch principle and sizepolicy
Installation steps and environment configuration of vs Code
Wapiti是什么以及使用教程
Pyqt5: Chapter 1, Section 1: creating a user interface using QT components - Introduction