PHP code example of amirezaeb / heroqr

1. Go to this page and download the library: Download amirezaeb/heroqr 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/ */

    

amirezaeb / heroqr example snippets


use HeroQR\Core\QRCodeGenerator;

$qrCode = (new QRCodeGenerator())
    ->setData('https://test.org') 
    ->generate();

$qrCode->saveTo('qrcode'); 

use HeroQR\Core\QRCodeGenerator;
use HeroQR\DataTypes\DataType;

$qrCode = (new QRCodeGenerator())
    ->setData('[email protected]', DataType::Email)
    ->setBackgroundColor(255, 255, 255, 0)
    ->setColor(0, 100, 200)
    ->setSize(1000)
    ->setLogo('../assets/HeroExpert.png', 100)
    ->setMargin(0)
    ->setEncoding('CP866')
    ->setErrorCorrectionLevel('Medium')
    ->setBlockSizeMode('None')
    ->setLabel(
        label: 'To Contact Me, Just Scan This QRCode',
        textAlign: 'left',
        textColor: ['r' => 0, 'g' => 100, 'b' => 200],
        fontSize: 35,
        margin: [15, 15, 15, 15]
    )
    ->generate('webp');

$qrCode->saveTo('custom-qrcode');

use HeroQR\Core\QRCodeGenerator;

$qrCode = (new QRCodeGenerator())
    ->setData('https://github.com/amirezaeb/heroqr')
    ->setSize(800)
    ->setBackgroundColor(0, 0, 0, 0) 
    ->setColor(0, 100, 200)
    ->generate('svg',[
            'Shape' => 'S2',
            'Marker' => 'M2',
            'Cursor' => 'C2'
        ]);

$qrCode->saveTo('custom-qr');

use HeroQR\Core\QRCodeGenerator;

$qrCode = (new QRCodeGenerator())
    ->setData('https://test.org') 
    ->generate();

# Raw binary string
$string = $qrCode->getString();

# Matrix object
$matrix = $qrCode->getMatrix();

# 2D array
$matrixArray = $qrCode->getMatrixAsArray();

# Base64 Data URI
$dataUri = $qrCode->getDataUri();

# Save to file
$qrCode->saveTo('qr_code_output');