1. Go to this page and download the library: Download barretzhi/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/ */
barretzhi / qrcode example snippets
use Endroid\QrCode\QrCode;
// Create a QR code
$qrCode = new QrCode('Life is too short to be generating QR codes');
$qrCode->setSize(300);
// Advanced options
$qrCode
->setQuietZone(2)
->setErrorCorrectionLevel('H')
->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0])
->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0])
->setLabel('Scan the code', 16, __DIR__.'/../font/open_sans.ttf')
->setLogo(__DIR__.'/../logo/endroid.png', 50)
;
// now we can output the QR code
header('Content-Type: '.$qrCode->getContentType(QrCode::TYPE_PNG));
$qrCode->write(QrCode::TYPE_PNG);
// save it to a file (uses type guessing)
$qrCode->write(__DIR__.'/qrcode.png');
// create a response object
$response = new Response(
$qrCode->write(QrCode::TYPE_SVG),
Response::HTTP_OK,
['Content-Type' => $qrCode->getContentType(QrCode::TYPE_SVG)])
;
// app/AppKernel.php
public function registerBundles()
{
$bundles = [
// ...
new Endroid\QrCode\Bundle\EndroidQrCodeBundle(),
];
}