PHP code example of jamal / laravel-qrcode

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

    

jamal / laravel-qrcode example snippets


use QrCode;

echo QrCode::text('Hello World')->renderer('svg')->toSvg();

QrCode::text('Hello')->toSvg();
QrCode::text('Hello')->renderer('gd')->toPng();

QrCode::text('Save')->renderer('svg')->save(storage_path('app/qr.svg'));
QrCode::text('Save')->renderer('gd')->save(storage_path('app/qr.png'));

return QrCode::text('Hello')->toSvgResponse();
// or
return QrCode::text('Hello')->renderer('gd')->toPngResponse();

$uri = QrCode::text('Embed')->toDataUri('svg'); // or 'png'

QrCode::text('Critical')->ecc('H')->version(2)->foreground('#111111')->background('#ffffff')->toSvg();
QrCode::text('Transparent')->background('transparent')->toSvg();

QrCode::text('WIFI:S:Home;T:WPA;P:secret;;')->toSvg();

$vcard = "BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL:+123456789\nEMAIL:[email protected]\nEND:VCARD";
QrCode::text($vcard)->toSvg();

QrCode::text('ABCD-1234 $%*+-./:')->toSvg(); // Alphanumeric mode

return [
    'version' => null, // auto
    'ecc' => 'M',
    'margin' => 4,
    'scale' => 10,
    'renderer' => 'svg', // svg|gd|imagick
    'fg_color' => '#000000',
    'bg_color' => '#ffffff',
    'eci' => false,
    'cache' => false,
    'cache_ttl' => 3600,
];