PHP code example of golivehost / php-qrcodegen

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

    

golivehost / php-qrcodegen example snippets




// Include Composer's autoloader
or;

// Instantiate the QRCodeGenerator class
$golivehost = new QRCodeGenerator();

// Set data to encode in the QR code
$golivehost->setData('Sample data for the QR code');

// Set QR code size
$golivehost->setSize('300x300');

// Set label for the QR code
$golivehost->setLabel('Sample QR Code Label');

// Save the generated QR code
$golivehost->saveQR('qr_code_with_label.png');

echo "QR code with label saved as qr_code_with_label.png\n";



// Include Composer's autoloader
or;

// Instantiate the QRCodeGenerator class
$golivehost = new QRCodeGenerator();

// Set data to encode in the QR code
$golivehost->setData('Sample data for the QR code');

// Set QR code size
$golivehost->setSize('300x300');

// Do not set any label for the QR code
$golivehost->saveQR('qr_code_without_label.png');

echo "QR code without label saved as qr_code_without_label.png\n";



// Include Composer's autoloader

// Generate and save the QR code with a label
QRCodeUtils::generateAndSave('Sample data for the QR code', 'qr_code_sample.png', '300x300', 'Sample QR Code Label');

echo "QR code with label saved as qr_code_sample.png\n";

composer