How to Generate QR Code using Laravel

In this post we will learn how to generate QR Code using laravel.Laravel provides QR Code package which we will use, using it we can generate different kind of QR code. You have to install

Bacon/BaconQrCode package and then you have to register it with provider array inside config/app.php


Step 1: Install Laravel

Step 2: Install QR Package

Step 3: Register QR Service

Step 4: Create one controller

Step 5: Create Route

Step 6: Create blade view file for QR Code

Step 7: Run Application

Install Laravel

Using composer below command we can install laravel , go in xampp, open CMD and run below command.

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

Get in laravel application

cd qrcode

Install QR Package

Run below command for installing QR Package with your application

composer require simplesoftwareio/simple-qrcode

Inject QR service inside provider array inside config/app.php

'providers' => [

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

Create new controller using php artisan command

php artisan make:controller QrController

Create route in web.php


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\QrController;
| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!

Route::get('/', function () {
    return view('welcome');


Create View file

Create one view file inside resources/views/viewqrcode.blade.php directory, and call it inside controller function.


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class QrController extends Controller
    public function index()
        return view("viewqrcode");

Blade complete code

<!DOCTYPE html>
    <title>Generate QR Using Laravel</title>
    <link href="" rel="stylesheet"/>
            <h2> QR Code</h2>
            {!! QrCode::size(200)->generate('RemoteStack') !!}


Now Run application using below command

php artisan serve

Access QR route

Leave a Reply

Your email address will not be published. Required fields are marked *