How to Generate the QR code in Laravel

In this article, I will share with you how to Generate the QR code in Laravel

We are going to Configure Laravel Project.

#1: Install Laravel Project

Install Laravel Project by the typing following command.

$ composer create-project --prefer-dist laravel/laravel laravel-qr-code

#2 : Install Required Packages

We have required following packages for integrate yajra datatable in our laravel application.

composer require simplesoftwareio/simple-qrcode

Now open config/app.php file and add service provider and aliase.

'providers' => [

'aliases' => [
    'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class

#3: Define Route

We register all route in a web.php file.

Route::get('qr-code-generate', function () {
  			->generate("Qr Code Generate", public_path('images/qrcode.png'));
	return view('qrCode');

#4: Create Blade file

We can also create the QR code in blade file we need to create qr_code.blade.php for display qr code. so let's create blade file as like bellow code:

<!DOCTYPE html>
	    <title>Generate the QR Code in Laravel</title>
		<div class="row text-center">
		    <h1> QR Code Generator Example</h1>
		    {!! QrCode::size(250)->generate('Qr Code Generate'); !!}

You can run and check it.

I hope it will help you.