zoukankan      html  css  js  c++  java
  • YII2 生成二维码

    扩展

    1. 2amigos/qrcode-library

    https://qrcode-library.readthedocs.io/en/latest

    // in components config of Yii2 app
    
    'components' => [
    // ... 
        'qr' => [
            'class' => 'DaQrCodeComponentQrCodeComponent',
            // ... you can configure more properties of the component here
        ]
    // ...
    ]
    
    
    // on your controller's action 
    输出到浏览器
    
    $qr = Yii::$app->get('qr');
    
    Yii::$app->response->format = Response::FORMAT_RAW;
    Yii::$app->response->headers->add('Content-Type', $qr->getContentType());
    
    return $qr
        ->setText('https://2amigos.us')
        ->setLabel('2amigos consulting group llc')
        ->writeString();
    
    保存二维码 
    
    $qr->setText('https://2amigos.us')->writeFile(路径);//路径一定要有效 否则报内容空,会让你觉得二维码没写入内容

    直接调用

     $qr = (new DaQrCodeQrcode($url))->setSize(250)->setMargin(5);
    // 把图片保存到文件中:
    $qr->writeFile('路径');
    

      

    2.phpqrcode 

    http://phpqrcode.sourceforge.net/

  • 相关阅读:
    Supervisor安装与使用
    windows常用快捷键和指令
    搜索引擎使用技巧
    golang核心Goroutine和channel
    4、小程序原生底部菜单
    三、小程序值使用vant开发
    axios请求2
    3、小程序消息推送
    居中
    一、底部菜单
  • 原文地址:https://www.cnblogs.com/jimz/p/10178221.html
Copyright © 2011-2022 走看看