PHP code example of mojahed / eduplusqr

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

    

mojahed / eduplusqr example snippets



use Mojahed\EduplusQR;

// Simple usage
EduplusQR::quick("Hello World", "qr.png", 256);

// Fluent API
EduplusQR::create()
    ->text("https://eduplus-bd.com")
    ->output("qr.png")
    ->size(512)
    ->errorCorrection('H')
    ->generate();

use Mojahed\EduplusQR;

$qr = EduplusQR::create()
    ->text("Hello World from EduplusQR!")
    ->output("output/qr.png")
    ->generate();

if ($qr) {
    echo "QR code generated successfully!";
} else {
    print_r(EduplusQR::create()->errors);
}

$data = json_encode([
    'user_id' => 12345,
    'name' => 'John Doe',
    'email' => '[email protected]',
    'timestamp' => time()
]);

EduplusQR::create()
    ->text($data)
    ->output("user_qr.png")
    ->size(512)
    ->errorCorrection('H')
    ->generate();

$paymentData = json_encode([
    'merchant_id' => 'MERCH123',
    'amount' => 1500.50,
    'currency' => 'BDT',
    'invoice' => 'INV-' . uniqid()
]);

EduplusQR::create()
    ->text($paymentData)
    ->output("payment.png")
    ->size(400)
    ->errorCorrection('H')
    ->generate();

$base64 = EduplusQR::create()
    ->text("Base64 QR Code")
    ->output("temp_qr.png")
    ->generateBase64();

// Use in HTML
echo '<img src="data:image/png;base64,' . $base64 . '" />';

$binaryData = EduplusQR::create()
    ->text("Binary QR Code")
    ->output("temp_qr.png")
    ->generateAndReturn();

// Send as HTTP response
header('Content-Type: image/png');
echo $binaryData;