How to generate a QR Code in Laravel
today, we will learn How to generate a QR Code in Laravel. In this tutorial, I will give you an example of generating a QR Code with example in Laravel. I write an example step by step to generate a QR code in your Laravel 6 admin panel. so let’s follow a few steps to get this example :
Step 1: Install Laravel
Also Read: Install Laravel and Basic Configurations
Step 2: Install simple-qrcode Package
Now we are required to install simple-qrcode package for the QR code generator. open your terminal and run the command :
composer require simplesoftwareio/simple-qrcode
Now open config/app.php
/* config/app.php */
'providers' => [
SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class,
],
'aliases' => [
'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class,
],
Step 3: Create Route
/* routes/web.php */
<?php
Route::get('qr-code', function () {
\QrCode::size(500)
->format('png')
->generate('devnote.in', public_path('images/devnote.png'));
return view('qrcode');
});
Step 4: Create a Blade file
create qrCode.blade.php.
/* resources/views/qrCode.blade.php */
<!DOCTYPE html>
<html>
<head>
<title>Qr Code create</title>
</head>
<body>
<div class="text-center">
<h1>Laravel - QR Code Generator Example</h1>
{!! QrCode::size(250)->generate('devnote.in'); !!}
</div>
</body>
</html>