zoukankan      html  css  js  c++  java
  • Yii 安装二维码扩展Qrcode

    比如要添加 https://github.com/2amigos/yii2-qrcode-helper 生成二维码的 这个扩展
    第一种方法 :
        1、打开根目录的composer.json, 在require那里加上 "2amigos/yii2-qrcode-helper" : "~1.0",如图
        "require": {

         "php": ">=5.4.0",
         "yiisoft/yii2": "*",
         "yiisoft/yii2-bootstrap": "*",
         "yiisoft/yii2-swiftmailer": "*",
      "2amigos/yii2-qrcode-helper" : "~1.0"

        },

       2、命令行切换到根目录, 运行composer update,等几分钟就好了

       3、按照扩展的说明做些配置
    第二种方法 :

    php composer.phar require 2amigos/yii2-qrcode-helper:~1.0  
    composer require 2amigos/yii2-qrcode-helper:~1.0
    在SiteController.php中

    1 use dosamigosqrcodeQrCode;
    2 use dosamigosqrcodeformatsMailTo;
    3 
    4 public function actionQrcode() {
    5         $mailTo = new MailTo(['email' => 'xp796@163.com']);
    6         return QrCode::png($mailTo); 
    7     }

    在index.php 中

    1    <img src="<?= Url::to(['site/qrcode'])?>" />

    成功

  • 相关阅读:
    07.28周四
    07.27 约束自己
    07.26
    07.25新的一周,踏实,努力
    07.21 智能充电开发
    07.20小笔记
    07.20 html5的适配flexible
    07.19 Linux命令 cd
    SpringBoot简介和Banner
    webpack生产环境配置
  • 原文地址:https://www.cnblogs.com/xp796/p/5569537.html
Copyright © 2011-2022 走看看