Laravel 7/8/9 QR Code Generate Example
Comment (0)
Admin
292
Hi Dev,
In this example, i will show you how to generate qr code in laravel 8. In this article, we will implement a laravel 7/8/9 qr code example. In this article, we will implement a how to create qr code in laravel 8. if you want to see example of how to make qr code in laravel 8 then you are a right place.
Step 1: Install simple-qrcode Package
Now we require to install simple-qrcode package for qr code generator, that way we can use it's method. So Open your terminal and run bellow command.
composer require simplesoftwareio/simple-qrcode
Now open config/app.php file and add service provider and aliase.
config/app.php
'providers' => [
....
SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class
],
'aliases' => [
....
'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class
],
Step 2: Create Route
In this step, we will create one route for testing example. So, let's add new route on that file.
routes/web.php
<?php
Route::get('qr-code-g', function () {
\QrCode::size(500)
->format('png')
->generate('nijwel.xyz', public_path('images/qrcode.png'));
return view('qrCode');
});
Step 4: Create Blade file
now we need to create qrCode.blade.php for display qr code. so let's create blade file as like bellow code:
resources/views/qrCode.blade.php
<!DOCTYPE html>
<html>
<head>
<title>How to Generate QR Code in Laravel 7/8/9? - nijwel.xyz</title>
</head>
<body>
<div class="visible-print text-center">
<h1>Laravel 7/8/9 - QR Code Generator Example</h1>
{!! QrCode::size(250)->generate('nijwel.xyz'); !!}
<p>example by nijwel.xyz</p>
</div>
</body>
</html>
Comments (0)
Your Comment