1. Go to this page and download the library: Download yoha/qr 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/ */
yoha / qr example snippets
use Yoha\Qr\Core\QrBuilder;
$qrBuilder = new QrBuilder();
$qrBuilder->setWriterType('pdf') // Change output type to PDF
->setData('http://yohacodes.pro.et')
->generate();
use Yoha\Qr\Core\QrBuilder;
// Include the Composer autoloader if you're using YohaQR in a custom PHP project
Generate the QR code and obtain the Data URI
$result = $qrBuilder->getUri();
use Yoha\Qr\QrBuilder;
$qrBuilder = new QrBuilder();
// Configure QR code with advanced settings
$result = $qrBuilder->setWriterType('png') // Change type if needed: 'pdf', 'webp', or 'svg'
->setData('https://example.com') // Data to encode
->setLogoPath(__DIR__ . '/assets/logo.png')// Set the path to your logo image
->setLogoResizeToWidth(50) // Resize logo width (in pixels)
->setLogoPunchoutBackground(true) // Optionally remove logo background
->setMargin(2) // Set the QR code margin
->generate();
// Retrieve the Data URI
$uri = $result->getDataUri();
use Yoha\Qr\QrBuilder;
$qrBuilder = new QrBuilder();
// Generate a PDF QR code and save the file
$result = $qrBuilder->setMargin(2)
->setWriterType('pdf')
->setData('Testing SaveFile')
->saveToFile(name: 'testing_pdf', path: __DIR__ . '/../storage/files/');
// Retrieve the Data URI for the saved file
$uri = $result->getDataUri();
use Yoha\Qr\QrBuilder;
$qrBuilder = new QrBuilder();
// Generate a QR code (change the writer type as needed: 'png', 'pdf', or 'svg')
$result = $qrBuilder->setMargin(2)
->setWriterType('svg')
->setData('Testing SaveFile')
->generate();
// Render the QR code appropriately based on its MIME type
echo $qrBuilder->readFile($result);