[Laravel] LAMP+Laravel 學習筆記-Simple QrCode

產生qrcode 
1.套件simple-qrcode
   參考:https://www.simplesoftware.io/docs/simple-qrcode
2.安裝:修改config/app.php
3.產生QrCode圖檔
   或輸出base64

 

1.參考套件:simple-qrcode
    https://www.simplesoftware.io/docs/simple-qrcode
2.安裝
 a.修改composer.json

"require": {
    "simplesoftwareio/simple-qrcode": "~1.5"
}

b.執行composer update
c.修改config/app

'providers' => [

     ......
        //barcode
        SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class,
    ],

 'aliases' => [

    ......
        'QrCode'=> SimpleSoftwareIO\QrCode\Facades\QrCode::class,
    ],

 3.產生QrCode圖檔

a.產生html
   QrCode::size(大小)->generate("內容")

{!! QrCode::size(100)->generate($qrCodeUrl) !!}


b.直接輸出base64

<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(100)->generate($qrCodeUrl)) !!} ">


c.進階用法
 

size:設定大小
color:設定顏色
backgroundColor:設定背景顏色
format:圖檔格式
QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate('Make me a QrCode!');
QrCode::format('png')->size(399)->color(40,40,40)->generate('Make me a QrCode!');