To generate Qr Code with Laravel, Quar references packages provided by Bacon/BaconQrCode and simplesoftwareio/simple-qrcode. The Quar package is a new qr code generation package with compatibility for Laravel 10, Laravel 11, Laravel 12, Laravel 13 and Php 8.2, Php 8.3, Php 8.4, Php 8.5.
- PHP 8.2+
- Laravel 10+
Use Composer to install it:
composer require tuncaybahadir/quar
use tbQuar\Facades\Quar;
$qr = Quar::generate('Quar package create qr code');And use it in your blade template this way:
<div>
{{ $qr }}
</div>use tbQuar\Facades\Quar;
$qr = Quar::size(61)
->generate('Quar package create qr code');QR codes have 40 versions (1-40); a higher version provides a larger grid and therefore more data capacity. By default the version is selected automatically based on the content and the error correction level. You may force a specific version with the version() method.
Any integer between 1 and 40 is accepted. For readability, VERSION_1 through VERSION_40 constants are also available on the Quar facade, so version(13) and version(Quar::VERSION_13) are equivalent.
use tbQuar\Facades\Quar;
$qr = Quar::version(13)
->generate('Quar package create qr code');
// Equivalent, using the constant
$qr = Quar::version(Quar::VERSION_13)
->generate('Quar package create qr code');
$qr = Quar::size(300)
->eye('ring')
->style('round', 0.9)
->version(Quar::VERSION_13)
->margin(2)
->gradient(20, 192, 241 , 164, 29, 52 , 'vertical')
->generate('Quar package create qr code');
$qr = Quar::size(300)
->eye('square')
->eyeColorFromHex('0', '#710616', '#710616')
->eyeColorFromHex('1', '#7ab9e7', '#7ab9e7')
->eyeColorFromHex('2', '#fcb811', '#fcb811')
->style('round', 0.9)
->version(Quar::VERSION_25)
->margin(2)
->gradient(20, 192, 241 , 164, 29, 52 , 'vertical')
->generate('Quar package create qr code');
$qr = Quar::size(500)
->margin(2)
->version(Quar::VERSION_40)
->generate('Version 40 (177×177). Content: "Version 40 QR Code can contain up to 1852 chars ..." (and followed by four paragraphs of ASCII text describing QR codes). The text refers to a QR Code with a "Level H" error correction. Other levels provide higher capacity.');Attention : The version must be between 1 and 40. If the content does not fit into the requested version, a WriterException is thrown. When version() is not used, the smallest fitting version is selected automatically, exactly as before.
square: Default Marker Typeroundedcirclering
use tbQuar\Facades\Quar;
$qr = Quar::eye('rounded')
->generate('Quar package create qr code');square: Default Patterndotroundstarvertigo
Attention : The maximum smoothness value for square, dot and round designs is 0.9 and the maximum smoothness value for star and vertigo designs is 0.5.
use tbQuar\Facades\Quar;
$qr = Quar::style('dot', 0.9)
->generate('Quar package create qr code');verticalhorizontaldiagonalinverse_diagonalradial
use tbQuar\Facades\Quar;
$qr = Quar::eye('rounded')
->size(161)
->gradient(20, 192, 241 , 164, 29, 52 , 'vertical')
->generate('Quar package create qr code');use tbQuar\Facades\Quar;
$qr = Quar::eye('square')
->eyeColor(0, 113, 6, 22, 113, 6, 22)
->eyeColor(1, 122, 185, 231, 122, 185, 231)
->eyeColor(2, 252, 184, 17)
->size(161)
->generate('Quar package create qr code');use tbQuar\Facades\Quar;
$qr = Quar::eye('square')
->eyeColorFromHex('0', '#710616', '#710616')
->eyeColorFromHex('1', '#7ab9e7', '#7ab9e7')
->eyeColorFromHex('2', '#fcb811', '#fcb811')
->size(161)
->generate('Quar package create qr code');use tbQuar\Facades\Quar;
$qr = Quar::color(50, 168, 82)
->size(161)
->eye('circle')
->generate('Quar package create qr code');use tbQuar\Facades\Quar;
$qr = Quar::color('#32a852')
->size(161)
->eye('circle')
->generate('Quar package create qr code');use tbQuar\Facades\Quar;
$qr = Quar::color('#710616')
->backgroundColor('#7ab9e7')
->size(261)
->eye('circle')
->generate('Quar package create qr code');use tbQuar\Facades\Quar;
$qr = Quar::color(113, 6, 22)
->backgroundColor(122, 185, 231)
->size(261)
->eye('circle')
->generate('Quar package create qr code');use tbQuar\Facades\Quar;
$qr = Quar::color(235, 12, 83)
->size(161)
->eye('rounded')
->eyeColor(0, 113, 6, 22, 113, 6, 22)
->eyeColor(1, 122, 185, 231, 122, 185, 231)
->eyeColor(2, 252, 184, 17)
->generate('Quar package create qr code');use tbQuar\Facades\Quar;
$qrCodeFileName = md5(random_int(0, 9999999).date('H:i:s d.m.Y')).'_qr_code';
$qrCodeData = 'Quar package create qr code';
$qrCodeDirectory = storage_path('app/public/qr-code-images/');
Quar::format('png')
->color(155, 155, 200)
->size(200)
->eye('rounded')
->generate($qrCodeData, $qrCodeDirectory.$qrCodeFileName.'.png');
$qrCode = url('storage/qr-code-images/'.$qrCodeFileName.'.png');And use it in your blade template this way:
<div>
<img src="{{ $qrCode }}" />
</div>use tbQuar\Facades\Quar;
$qrCodeFileName = md5(random_int(0, 9999999).date('H:i:s d.m.Y')).'_qr_code';
$qrCodeData = 'Quar package create qr code';
$qrCodeDirectory = storage_path('app/public/qr-code-images/');
Quar::format('png')
->setPngCompression(50)
->color(155, 155, 200)
->size(200)
->eye('rounded')
->generate($qrCodeData, $qrCodeDirectory.$qrCodeFileName.'.png');
$qrCode = url('storage/qr-code-images/'.$qrCodeFileName.'.png');Attention !!! : Due to a bug in the BaconQrCode package, you must set the margin value to 1 or higher during logo insertion. Otherwise the qr code is generated incorrectly.
Example 1:
use tbQuar\Facades\Quar;
$qr = Quar::format('png')
->margin(1)
->merge(public_path('php.png'), .2, true)
->size(400)
->generate('Quar package create qr code');
return view('test', [
'qrCode' => base64_encode($qr),
]);Example 2:
use tbQuar\Facades\Quar;
$qr = Quar::format('png')
->margin(1)
->eye('rounded')
->merge(public_path('php.png'), .3, true)
->size(200)
->gradient(100, 20, 5 , 7, 9, 12 , 'VERTICAL')
->generate('Quar package create qr code');
return view('test', [
'qrCode' => base64_encode($qr),
]);And use it in your blade template this way:
<div>
<img src="data:image/png;base64,{{ $qrCode }}" />
</div>Example :
use tbQuar\Facades\Quar;
$qr = Quar::format('png')
->margin(1)
->when(($logo = config('app.company.logo')) && file_exists($logo))
->merge($logo, .25, absolute: true)
->size(400)
->generate('Quar package create qr code', $path);
return view('test', [
'qrCode' => base64_encode($qr),
]);Example :
use tbQuar\Facades\Quar;
$qr = Quar::size(300)
->withText('Quar Code Package')
->generate('Quar package create qr code');Example Result :
Example :
use tbQuar\Facades\Quar;
$qr = Quar::size(300)
->withText('Quar Code Package')
->configureText(function($text) {
$text->setTextColor('#54ac6e')
->setFontSize(12)
->setPosition('top-right')
->setPadding(25)
->setBackgroundColor('#151521')
//->setFont('/path/to/font.ttf')
->setBackgroundOpacity(0.1);
})
->generate('Quar package create qr code');Example Result :
top,bottom: Default Position,left,right,top-left,top-right,bottom-left,bottom-right,
Example :
use tbQuar\Facades\Quar;
$qr = Quar::size(300)
->withText('🇹🇷 Türkiye 🇹🇷')
->configureText(function($text) {
$text->setTextColor('#ce2026')
->setFontSize(30)
->setPosition('top')
->setBackgroundOpacity(0.1);
})
->generate('Quar package create qr code');Example Result :
Pull requests and issues are more than welcome.






























