ItSolutionStuff.com

Laravel 8 QR Code Generate Example

By Hardik Savani • November 5, 2023
Laravel

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 8 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.

simple-qrcode is a composer package for generate qr code in your laravel 8 application. simple-qrcode provide to send sms and email with generated qr code. you can create qr code for geo, phoneNumber, birthdate using simple qrcode package.

after generating qr code, we might be require to write code for scan code using jquery. if you same requirement for scan qr code using jquery then you can follow my this tutorial: qr code scanner using instascan js.

Here, i write example step by step to generate qr code in your laravel 5 admin panel. so let's follow few steps to get this example:

Preview:

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 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 3: 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('ItSolutionStuff.com', 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 8? - ItSolutionStuff.com</title>

</head>

<body>

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

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

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

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

</div>

</body>

</html>

Now you can run and check it.

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel 8 REST API with Passport Authentication Tutorial

Read Now →

Laravel 8 Resource Route and Controller Tutorial Example

Read Now →

Laravel 8 Flash Message Tutorial Example

Read Now →

Laravel 8 Send Mail using Queue Example

Read Now →

Laravel 8 Ajax Post Request Example

Read Now →

Laravel 8 Import Export Excel and CSV File Tutorial

Read Now →

Laravel 8 Guzzle Http Client Request Example

Read Now →

Laravel 8 Livewire CRUD with Jetstream & Tailwind CSS

Read Now →

Laravel 8 Send Mail using Gmail SMTP Server

Read Now →

Laravel 8 Mail | Laravel 8 Send Email Tutorial

Read Now →

How to Create Service in Angular 8 using cli?

Read Now →