PHP code example of globus-studio / phpqrcode

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

    

globus-studio / phpqrcode example snippets


use GlobusStudio\QRCode\QRCode;

// SVG string
$svg = QRCode::svg('https://example.com');

// PNG as data URI (II art
echo QRCode::string('https://example.com');

// Raw boolean matrix
$matrix = QRCode::matrix('https://example.com');

use GlobusStudio\QRCode\QRCode;
use GlobusStudio\QRCode\ErrorCorrection\ErrorCorrectionLevel;

$svg = QRCode::svg('data', [
    'level' => ErrorCorrectionLevel::H,
    'size' => 4,
    'margin' => 2,
    'mask' => 3,            // fixed mask 0-7 (skips auto-selection, 17x faster)
    'foreground' => '#000000',
    'background' => '#ffffff',
]);

// ~180ms per QR (auto mask selection)
$svg = QRCode::svg($data);

// ~11ms per QR (fixed mask, 17x faster)
$svg = QRCode::svg($data, ['mask' => 0]);

use GlobusStudio\QRCode\QRCode;
use GlobusStudio\QRCode\ErrorCorrection\ErrorCorrectionLevel;
use GlobusStudio\QRCode\Renderer\SvgRenderer;

$qr = new QRCode('https://example.com', ErrorCorrectionLevel::H);
$svg = $qr->render(new SvgRenderer(['size' => 6]));
$matrix = $qr->getMatrix();