PHP code example of apirone / php-qr-code

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

    

apirone / php-qr-code example snippets




use Apirone\Lib\PhpQrCode\QrCode;

// Quick static method with base64 encoded PNG

$data = 'Lorem ipsum dolor sit amet';
$options = [
    's' => 'qrm',
    'fc' => '#000000',
    'bc' => '#FFFFFF',
    // ...
];

$base64_qr_encoded = QrCode::png($data, $options);
echo '<img src="' . $base64_qr_encoded . '"> ';

// Create and use qr instant
$qr = QRCode::init($data, $options); // $data & $options are optional

// Also you can use chain to set some options (not all)
$options['s'] = 'qrq';
$image_encoded = $qr->data($data)->options($options)->base64();

echo '<img src="' . $image_encoded . '"> ';

$image_raw = QRCode::init()
    ->data($data)
    ->levelHigh()
    ->density(0.5)
    ->raw();

echo '<img src="data:image/png;base64,' . base64_encode($image_raw) . '"> ';


$options = [
    's' => 'qrl',
    'fc' => '#000000',
    'bc' => '#FFFFFF',
    // ...
];