PHP code example of avdeb / qr-php

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

    

avdeb / qr-php example snippets



Avdeb\QrPhp\QRCodeGenerator;

$qr = new QRCodeGenerator(['size' => 8, 'margin' => 4, 'errorCorrection' => 'M']);

// Format follows the extension: .svg or .png
if (!$qr->generate('https://example.com', __DIR__ . '/example.png')) {
    echo "Could not write file\n";
}
$qr->generate('https://example.com', __DIR__ . '/example.svg');


Avdeb\QrPhp\QRCodeGenerator;

$qr = new QRCodeGenerator(['size' => 6, 'foreground' => '#1a237e']);
$text = (string) ($_GET['text'] ?? 'Hello, world!');

header('Content-Type: image/png');
echo $qr->render($text, 'png');
// or: header('Content-Type: image/svg+xml'); echo $qr->render($text, 'svg');


Avdeb\QrPhp\QRCodeGenerator;
use Avdeb\QrPhp\VCard;

$card = new VCard(
    firstName: 'Jane',
    lastName: 'Doe',
    phone: '+15551234567',
    email: '[email protected]',
    organization: 'Acme, Inc.',
);

$qr = new QRCodeGenerator(['errorCorrection' => 'Q']);
$qr->generate($card->toString(), __DIR__ . '/jane.svg');