xxxxxxxxxx
<?php
require __DIR__ . '/vendor/autoload.php'; // Require the Composer autoloader
use Endroid\QrCode\QrCode;
// Create a new instance of QR code
$qrCode = new QrCode('Hello, World!');
// Set options if needed
$qrCode->setSize(300);
$qrCode->setMargin(10);
// Output the QR code directly to the browser or save it to a file
header('Content-Type: '.$qrCode->getContentType());
echo $qrCode->writeString();
// Alternatively, if you want to save the QR code to a file:
// $qrCode->writeFile('path/to/save/image.png');
xxxxxxxxxx
It's worth adding that, in addition to the QR codes library posted by @abaumg, Google provides a QR Codes API QR Codes APImany thanks to @Toukakoukan for the link update.
To use this , basically:
https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8
300x300 is the size of the QR image you want to generate,
the chl is the url-encoded string you want to change into a QR code, and
the choe is the (optional) encoding.
The link, above, gives more detail, but to use it just have the src of an image point to the manipulated value, like so:
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8" title="Link to Google.com" />
xxxxxxxxxx
Reference:
https://www.positronx.io/how-to-quickly-generate-barcode-in-laravel-application/