当前位置:网站首页>php laravel框架生成二维码
php laravel框架生成二维码
2022-08-02 03:26:00 【陌潇】
一、配置
1.在项目根目录输入命令
composer require simplesoftwareio/simple-qrcode 1.3.*
2.在config/app.php 的 providers 数组里添加服务提供者.
SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class
3.在app/config/app.php 的 aliases 数组里添加别名.
'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class
4.配置工作就做完了,下面就开始引入使用了
二、应用实例
1.命名空间引入
use SimpleSoftwareIO\QrCode\Facades\QrCode;
2.生成普通二维码(扫描之后内容为填写的字符转)
QrCode::generate('Hello World!');
3.生成中文字符的二维码(扫描之后内容为填写的字符转)
QrCode::encoding('UTF-8')->generate('你好世界');
4.将生成的指定的图片格式二维码保存到指定路径
QrCode::encoding('UTF-8')->format('png')->generate('我是内容',public_path('image/test.png'));
5.修改二维码图片的大小
QrCode::format('png')->size(100)->encoding('UTF-8')->generate('我是内容',public_path('img/qrcode.png'));
6.改变 二维码颜色
QrCode::format('png')->size(100)->color(255,0,255)->generate('Hello,LaravelAcademy!',public_path('qrcodes/qrcode.png'));
7.改变 二维码 颜色与背景颜色(形成反差)
QrCode::format('png')->size(100)->color(255,0,255)->backgroundColor(255,255,0)->margin(100)->generate('Hello,LaravelAcademy!',public_path('qrcodes/qrcode.png'));
8.改变 二维码距边框的距离
QrCode::format('png')->size(100)->color(255,0,255)->backgroundColor(255,255,0)->margin(100)->generate('Hello,Laravel!',public_path('qrcodes/qrcode.png'));
9.合并水印到二维码 参数1为图片地址 参数2为 所占百分比 如 .15
QrCode::format('png')->size(200)->merge('参数1',参数2)->generate('LaravelAcademy',public_path('qrcodes/qrcode.png'));
三、其他设置
1.边距设置
也支持设置边距. 设置方式如下:
QrCode::margin(100);
2.容错级别设置
改变二维码的容错级别也很方便. 只要这么设置:
QrCode::errorCorrection('H');
容错级别 说明
L 7% 的字节码恢复率.
M 15% 的字节码恢复率.
Q 25% 的字节码恢复率.
H 30% 的字节码恢复率.边栏推荐
- (1) print()函数、转义字符、二进制与字符编码 、变量、数据类型、input()函数、运算符
- Kali环境下Frida编写脚本智能提示
- Introduction to PHP (self-study notes)
- hackmyvm-random walkthrough
- 3000字入门图神经网络
- Anaconda报错:An unexpected error has occurred. Conda has prepared the above report 解决办法
- 一个网络安全小白鼠的学习之路—nmap高级用法之脚本使用
- Orasi: 1 vulnhub walkthrough
- Orasi: 1 vulnhub walkthrough
- ES6 three-dot operator, array method, string extension method
猜你喜欢

Shuriken: 1 vulnhub walkthrough

Solve the problem that the 5+APP real machine test cannot access the background (same local area network)

超级云APP,陪伴您一起成长的软件

【一句话攻略】彻底理解JS中的回调(Callback)函数

会计账簿、会计账簿概述、会计账簿的启用与登记要求、会计账簿的格式和登记方法

Command Execution Vulnerability

(1) the print () function, escape character, binary and character encoding, variables, data type, the input () function, operator

财产清查概述、 全面清查的情况、局部清查的情况、财产清查的方法、财产清查结果的处理

laravel 查询数据库获取结果如何判断是否为空?

Eric target penetration test complete tutorial
随机推荐
PHP realizes the automatic reverse search prompt of the search box
Warzone: 3 (Exogen) vulnhub walkthrough
对账、结账、错账更正方法、划线更正法、红字更正法、补充登记法
敏感信息泄露
重点考:金融资产概述、交易性金融资产的概念、交易性金融资产的账务处理(取得、持有。出售)、
CTF introductory notes ping
laravel 查询数据库获取结果如何判断是否为空?
17. JS conditional statements and loops, and data type conversion
(7) superficial "crawlers" process (concept + practice)
Offensive and defensive world - novice MISC area 1-12
考(重点理解哪些属于其他货币资金)、其他货币资金的内容、其他货币资金的账务处理(银行汇票存款、银行本票存款、信用卡存款、信用证保证金存款、存出投资款、外埠存款)
CTF入门之md5
uniapp | Compilation error after updating with npm update
hackmyvm: kitty walkthrough
uniapp | Problems with the use of the official map component
一个网络安全小白鼠的学习之路—nmap高级用法之脚本使用
The shooting range that web penetration must play - DVWA shooting range 1 (centos8.2+phpstudy installation environment)
CSRF(跨站请求伪造)
链动2+1无限循环系统,2022年起盘成功率超高的模式
Eric target penetration test complete tutorial