PHP code example of davidnineroc / qrcodeplus

1. Go to this page and download the library: Download davidnineroc/qrcodeplus library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

davidnineroc / qrcodeplus example snippets




avidNineRoc\Qrcode\Factory;
use DavidNineRoc\Qrcode\QrCodePlus;

/****************************************
 * 通过工厂方法,获取到你想创建二维码的样式
 * 现在仅有:color, image
 ****************************************/
$color = Factory::color(['#087', '#431', '#a2d', '#a2d',]);
// $image = Factory::image(imagecreatefrompng('DavidNineRoc.png'));


/****************************************
 * 实例化对象,并在 output 方法传入
 * $color 或者 $image
 ****************************************/
(new QrCodePlus)
    ->setText('DavidNineRoc')
    ->setMargin(50)
    ->setOutput(function($handle){
        header('Content-Type: image/jpeg');
        imagejpeg($handle);
    })
    ->output($color);