PHP code example of abduns / laravel-qrcode

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

    

abduns / laravel-qrcode example snippets


use Dunn\QrCode\Laravel\Facades\QrCode;

$svg = QrCode::svg('https://example.com');

use Dunn\QrCode\Laravel\Facades\QrCode;

$svg     = QrCode::svg('https://example.com');     // SVG markup (the default)
$png     = QrCode::png('https://example.com');     // raw PNG bytes (ext-gd)
$ascii   = QrCode::console('https://example.com'); // unicode block string
$builder = QrCode::create('https://example.com');  // raw core Builder

use Dunn\QrCode\Laravel\Facades\QrCode;
use Dunn\QrCode\Payload\VCard;

// vCard — compose the contact, then hand to the facade
$card = VCard::make('John Doe')
    ->withOrg('Acme')
    ->addPhone('+14155550123', VCard::TYPE_WORK)
    ->addEmail('[email protected]');

$svg = QrCode::svg($card);

use Dunn\QrCode\Renderer\Png\GdPngRenderer;

Route::get('/qr/{data}', fn (string $data) => response()->qrcode($data));

[
    'ecc'        => EccLevel::Medium,
    'renderer'   => 'svg',         // 'svg' | 'png' | 'console'
    'size'       => 300,
    'margin'     => 4,
    'foreground' => '#000000',
    'background' => '#ffffff',
]