zoukankan      html  css  js  c++  java
  • thinkphp5 与 endroid 二维码生成

    windows compser安装endroid/qrcode,自己安装好composer工具;

    1. 项目目录 文件 composer.json

    require 里添加 "endroid/qrcode": "2.5.1" (endroid版本根据php版本填写相应版本)

    配置中文镜像下载路径

    1 "repositories": {
    2         "packagist": {
    3             "type": "composer",
    4             "url": "https://packagist.phpcomposer.com"
    5         }
    6     }

    2. cmd 切换到项目目录输入命令

    composer require endroid/qrcode

    3. php控制器引入

     1      use EndroidQrCodeQrCode;
     2 
     3     $qrCode=new QrCode();
     4         $url = 'A150';
     5 
     6         $qrCode->setText($url)
     7             ->setSize(200)//大小
     8             ->setLabelFontPath(VENDOR_PATH.'endroidqrcodeassets
    oto_sans.otf')
     9             ->setErrorCorrectionLevel('high')
    10             ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
    11             ->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))
    12             ->setLabel('桌码  A150')
    13             ->setLabelFontSize(16);
    14 
    15         header('Content-Type: '.$qrCode->getContentType());
    16 
    17         ob_clean();  /*解决提示 图像错误,无法显示问题*/
    18 
    19         echo $qrCode->writeString();
    20         exit;
  • 相关阅读:
    zoj 3279 线段树 OR 树状数组
    fzu 1962 树状数组 OR 线段树
    hdu 5057 块状链表
    hdu3487 Play with Chain
    bzoj 1588营业额统计(HNOI 2002)
    poj2823 Sliding Window
    poj2828 Buy Tickets
    poj2395 Out of Hay
    poj3667 Hotel
    poj1703 Lost Cows
  • 原文地址:https://www.cnblogs.com/CcPz/p/9412360.html
Copyright © 2011-2022 走看看