入门安装此扩展的首选方法是通过composer。phpcomposer.pharrequire2amigos/qrcode-library:~1.1或添加"2amigos/qrcode-library":"^2.0"实际代码使用示例useDa\QrCode\Contracts\ErrorCorrectionLevelInterface;useDa\QrCode\QrCode;useDa\QrCode\Label;publicfunctiongetRoleList($param=null){$label=(newLabel('helloworld!!!'))//实例化文字->setFont(__DIR__.'/../resources/fonts/monsterrat.otf')//引入字体->setFontSize(12);//设置文字大小return(newQrCode("helloword!!!"))//生成内容->setErrorCorrectionLevel(ErrorCorrectionLevelInterface::HIGH)//容错级别->setLogo(__DIR__.'/data/logo.png')//设置logo->setLogoWidth(60)//设置logo大小->setSize(300)//二维码大小->setEncoding('UTF-8')//设置编码格式->setForegroundColor(51,153,255)//设置二维码颜色->setBackgroundColor(200,220,210)//设置背景颜色->setMargin(5)->setLabel($label)//设置二维码底部文字->writeDataUri();//导出方式为base64}
yii2学习笔记