How To Generate QR Code In Laravel 8

In this article, we will see how to generate QR code in laravel 8. we will generate QR code using the simplesoftwareio/simple-qrcode package in laravel 8. simplesoftwareio/simple-qrcode package is an easy-to-use PHP QR Code generator with first-party support for laravel 8.

So, let's see the laravel 8 QR code generate Example.

Using this simplesoftwareio/simple-qrcode package, you can generate a simple QR code, text QR code, or image QR code in laravel 8. Also, you can customize it as per requirements like color, size, text, height, width, etc.

You can read more on SimpleSoftwareIO simple-qrcode and also read Official Documentation.

So, let's see generate QR code in laravel 8 using simplesoftwareio/simple-qrcode.

Step 1: Install Laravel 8

Step 2: Configure Database

Step 3: Install simple-qrcode Package

Step 4: Create Controller

Step 5: Add Route

Step 6: Generate QR Codes in Blade View

Step 7: Run Laravel App


Step 1: Install Laravel 8

In this step, we will install laravel 8 using the below command.

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



Step 2: Configure Database

Now, we will set up database configuration in the .env file.



Step 3: Install simple-qrcode Package

In the step, we will install the simplesoftwareio/simple-qrcode package using the below command.

composer require simplesoftwareio/simple-qrcode



Step 4: Create Controller

Now, we will create QRCodeController using the below command.

php artisan make:controller QRCodeController

Add the below code into the App/Http/Controller/QRCodeController.php file.


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use QrCode;

class QRCodeController extends Controller
    public function index()
      return view('qr_code');


Step 5: Add Route

Now, we will add the qr-code route in the web.php file.


use App\Http\Controllers\QRCodeController;
Route::get('/qr-code', [QRCodeController::class, 'index'])->name('qr-code');



Step 6: Generate QR Codes in Blade View

In this step, we will create a qr_code blade file and add the below code in that file.


<!DOCTYPE html>
  <title>How To Generate QR Code In Laravel 8 - Techsolutionstuff</title>
  <link rel="stylesheet" href="" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <div class="container">
        <div class="row text-center mt-5">
            <div class="col-md-6">
                <h4>Simple QR Code</h4>
                {!! QrCode::size(150)->generate('') !!}
            <div class="col-md-6">
                <h4>Color Qr Code</h4>
                {!! QrCode::size(150)->backgroundColor(255,55,0)->generate('') !!}


Step 7: Run Laravel App

Now, we will run the laravel application using the below command.

php artisan serve



Now, open the below URL on your browser.



You might also like: