PHP code example of bnomei / kirby3-qrcode

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

    

bnomei / kirby3-qrcode example snippets


$qrcodeObject = new \Bnomei\QRCode([
    'Text' => 'https://github.com/bnomei/kirby3-qrcode',
]);
echo $qrcodeObject->html('qrcode-plugin.png');

// base64 encoded png image tag
// with $page->url() as Text
echo $page->qrcode()->html(
    $page->slug() . '.png' // image format detected from extension
);

$qrcodeFilename = $page->slug() . '.png';
$file = $page->file($qrcodeFilename);

if (!$file) {
    // short version
    $file = $page->qrcode()->save(
        $qrcodeFilename
    );
    
    // with all params
    $file = $page->qrcode()->save(
        $qrcodeFilename,
        'myfiletemplate', // or null
        [/* my content data array */],
        true // force overwrite
    );
}

echo $file; // outputs a img tag

$page->qrcode()->download(
    $page->slug() . '.png'
);

echo $page->qrcode([
    'margin' => 10,
    'encoding' => 'UTF-8',
    'foregroundColor' => new \Endroid\QrCode\Color\Color(0, 0, 0),
    'backgroundColor' => new \Endroid\QrCode\Color\Color(255, 255, 255),
    'labelText' => 'Scan the code',
    'logoPath' => __DIR__.'/../assets/images/getkirby.png',
    'size' => 200,
])->html(
    $page->slug() . '.png'
);



return [
    // other options...
    
    // set values for qrcode inside the panel
    'bnomei.qrcode.field' => [
        'foregroundColor' => new \Endroid\QrCode\Color\Color(126, 154, 191),
        'backgroundColor' => new \Endroid\QrCode\Color\Color(239, 239, 239),
        'size' => 128,
        'margin' => 0,
    ],
];

$page->qrcode(option('bnomei.qrcode.field', []))->download(
    $page->slug() . '.png'
);