Laravel 8 QR Code Generate Example | How to create QR code in laravel

 


 

Today I will show you how to create QR code using laravel 

it's very simple and easy 

at first you install laravel in your computer 

then you  will take  simple-qrcode Packag/

Step 1: Install Laravel 8

In first step, If you haven't installed laravel 8 in your system then you can run bellow command and get fresh Laravel project.

composer create-project --prefer-dist laravel/laravel blog

Step 2: Install simple-qrcode Package

Now you require to install simple-qrcode package for qr code generator, that way you 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 3: Create Route

In this step, I 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('basabaribd.com', public_path('images/qrcode.png'));

return view('qrCode');

});

Step 4: Create Blade file

now I 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 8? - basabaribd.com</title>

</head>

<body>

<div class="visible-print text-center">

<h1>Laravel 8 - QR Code Generator Example</h1>

{!! QrCode::size(250)->generate('basabaribd.com'); !!}

<p>example by basabaribd.com.</p>

</div>

</body>

</html>

Now you can run and check it.

#basabaribd #TsDurjoy

 

No comments

Powered by Blogger.