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/

  • 相关阅读:
    2-Rsync备份-全网备份
    1-Rsync备份-备份概述
    复杂声明学习总结
    EasyExcel的用法
    listvue
    解决Error: Cannot find module 'node-sass'问题
    Webpack
    babel的使用
    nodejs的使用
    vue入门
  • 原文地址:https://www.cnblogs.com/jimz/p/10178221.html
Copyright © 2011-2022 走看看