THINKPHP5 generate two-dimensional code
Using the PHP QRCode class library
Composer require Endroid/qrcode import Phpqrcode class Library
2. Class Library use
A $qrCode = new \endroid\qrcode\qrcode ();//instantiation
b Set up the parameters generated by the generation of the QR code
C Parameter resolution:
$setVersion = $qrCode setversion (5);//37*37
Set the version number, QR code symbol a total of 40 specifications of the Matrix, from 21x21 (version 1), to 177x177 (version 40), each version of the symbol than the previous version of the addition of 4 modules per side.
$setErrorCorrection = $qrCode seterrorcorrection (2);//Fault tolerance level, 2 fault tolerance rate: 30%
Fault tolerance level: 0:15%,1:7%,2:30%,3:25%
$setModuleSize = $qrCode setmodulesize (2);//Set the QR code module size
$setImageType = $qrCode setimagetype (' png ');//set QR code save type
$logo = ' uploads/accountpictrue/logo1.jpg ';//logo pictures
$setLogo = $qrCode, Setlogo ($logo);//Picture in the middle of QR code
$setLogoSize = $qrCode setlogosize (360);//Set logo size
$value = ' https://www.dongtianjr.com '; Two-dimensional code content
$setText = $qrCode SetText ($value);//Set Text to hide the QR code.
$setSize = $qrCode setSize (1024);//size after the generation of the QR code
$setPadding = $qrCode setpadding (48);//Set the border width of the QR code, default 16
$setDrawQuietZone = $qrCode Setdrawquietzone (true);//Set module spacing
$setDrawBorder = $qrCode Setdrawborder (true);//to the QR code plus a border ...
$text = ' xx sales, XX company! one or two ';
$setLabel = $qrCode-SetLabel ($text);//Add text underneath the generated picture
$setLabelFontSize = $qrCode setlabelfontsize (39);//generated text size,
$lablePath = ' uploads/qr/qr. TTF ';
$setLabelFontPath = $qrCode-Setlabelfontpath ($lablePath);//Set Label font
$color _foreground = [' r ' = + 108, ' g ' = = 182, ' b ' = = 229, ' a ' and ' = 0];
$setForegroundColor = $qrCode Setforegroundcolor ($color _foreground);//The color of the generated QR code
$color _background = [' r ' = + 213, ' g ' = = 241, ' b ' = = 251, ' a ' and ' = 0];
$setBackgroundColor = $qrCode-SetBackgroundColor ($color _background);//generated picture background color
$flieName = ' liukelk.jpg ';//two-dimensional code name
Save ($flieName) $qrCode;//Generate two-dimensional code
Note: If the label is garbled in Chinese, the Chinese font can be introduced.
Generated (slightly)
650) this.width=650; "src=" Http://www.thinkphp.cn/Uploads/editor/2017-05-25/592673416d33c.jpg "alt=" 592673416d33c.jpg "width=" height= "543"/>
650) this.width=650; "src=" Http://www.thinkphp.cn/Uploads/editor/2017-05-25/5926734f79c93.png "alt=" 5926734f79c93.png "width=" height= "490"/>
If it is local composer,copy to the line.
To copy
Vender/composer,
Vender/bacon,
Vender/endroid,
Vender/khanamiryan,
Vender/myclabs,
Vender/paragonie
This article refers to:
Http://www.thinkphp.cn/topic/48510.html
Http://www.thinkphp.cn/topic/40300.html
Now we recommend that you use Endroid/qrcode,
GitHub Address: Https://github.com/endroid/QrCode
There's a problem in the group discussion.
---------- recruit the future great God -----------------------
If you have altruistic heart, willing to help others, willing to share
If you encounter PHP problem, Baidu and asked the other groups still did not get answers
Welcome to join, PHP technical question and answer group, QQ Group: 292626152
Educational developments Help others, you will also get promotion!
In order to cherish everyone's valuable time, please do not chat!
May we help each other and make progress together!
Add message code, PHP,AJAX,THINKPHP,YII ...
---------- recruit the future great God ----------
THINKPHP5 generate QR code to display in template