Laravel 8 QR Code Generate Example

In this article, we will see laravel 8 QR code generate example. we will generate QR Code using a simple-qrcode package. So, we will learn how to create QR codes in laravel 8 using the simple package.

So, let's see how to create QR code in laravel 8, QR code generator laravel 8, simple QR code generator laravel 8, how to generate QR code in laravel 8, laravel 8 QR code generator, laravel 8 QR code generate, laravel simple QR code generator, custom QR code generate in laravel 8, laravel 8 create custom QR code generator.

Here, we are using the simple-qrcode package, This package is very simple to use and generates QR code in laravel 8, you can also learn from the official site of Simple QrCode.

Step 1: Install Simple QR Code Package

In the step, we will install the simple-qrcode package using CLI.

composer require simplesoftwareio/simple-qrcode



Step 2: Setup Configuration

In the app.php file add the service provider and alias.


'providers' => [



'aliases' => [

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



Step 3: Create Controller QRController

In this step, we will create QRController in the App\Http\Controllers path.

php artisan:make controller QRController



namespace App\Http\Controllers;
use Illuminate\Http\Request;
use SimpleSoftwareIO\QrCode\Facades\QrCode;

class QRController extends Controller

    public function index()
    	return view('qrcode.index');
    public function create()
        QrCode::generate('', '../public/QRCode.svg');
	    return redirect()->route('qrcode.index');

Three formats are currently supported; png, eps, and svg. To change the format use the following code:

Note: imagick is required in order to generate an png image.

QrCode::format('png');  //Will return a png image
QrCode::format('eps');  //Will return a eps image
QrCode::format('svg');  //Will return a svg image



You can change the size of a QR Code by using the size method. Simply specify the size desired in pixels using the following syntax.



The ability to change the margin around a QrCode is also supported. Simply specify the desired margin using the following syntax.



Using a phone number helper generates a QR code that can be scanned and then dials a number.



Step 4: Create Routes for QR Code Generate

Now, add routes on the web.php file

use App\Http\Controllers\QRController;

Route::get('qr_code/index', [QRController::class, 'index'])->name('qrcode.index');
Route::get('qr_code/create', [QRController::class, 'create'])->name('qrcode.create');



Step 5: Create Blade File

In this step create a blade file in the resource/views/qrcode/index.blade.php path.

<!DOCTYPE html>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>Laravel 8 QR Code Generate Example - Techsolutionstuff</title>
		<link rel="stylesheet" href="">

		<form class="text-center" action="{{route('qrcode.create')}}" method="get" accept-charset="utf-8">
			<div class="row mt-5">
				<div class="col-md-12">
					<h2>Laravel 8 QR Code Generate Example - Techsolutionstuff</h2>
					<button class="btn btn-success" type="submit">Generate</button> 
					<a href="{{asset('QrCode.svg')}}" class="btn btn-primary" download>Download</a><br>
					<img class="img-thumbnail" src="{{asset('QrCode.svg')}}" width="150" height="150" style="margin-top: 20px">

and also you can directly generate QR Code in the blade file using the below code.

{!! QrCode::generate(''); !!}


You might also like :


Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.