Laravel 8 Simple Qr Code Generator Example




Laravel 8 qr code generator app. In this example, i will share with you how to generate qr code in laravel 8 app using package. And also will learn how to generate QR code from the text or number, or make QR code from the image, or make color  QR code.

In this example, i will show you simple way to generate or create different types of QR codes in laravel web applications.

Laravel 8 Generate QR Code Example

  • Install Laravel 8 Application
  • Configure Database Detail
  • Install QR Code Package
  • Create Routes
  • Create Controller By Artisan
  • Create Blade View
  • Start Development Server

Install Laravel 8 Application

First Step, you need to download or install laravel web application new setup on your local machine. you can use the following command to download or install laravel application new setup:

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

If you want to install a specific version of laravel, you can follow the following tutorial

Configure Database Detail

After that, you will set up the database credentials in .env file. So open your .env file and update database credentials following:


Install QR Code Package

Next, you need to Install QR Code Package laravel package in your web applications. So go to your command prompt and run the following command to install the latest laravel QR Code Package:

composer require simplesoftwareio/simple-qrcode

When the package of QR Code is installed. After that this package will have to be registered in the Laravel web application of the app. For this, you can register this package of instruction follow below.


'providers' => [



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


Create Routes

Next step, go to routes/web.php file and update the following routes into your file:

use App\Http\Controllers\GenerateQrCodeController;

Route::get('simple-qr-code', [GenerateQrCodeController::class, 'simpleQrCode']);
Route::get('color-qr-code', [GenerateQrCodeController::class, 'colorQrCode']);
Route::get('image-qr-code', [GenerateQrCodeController::class, 'imageQrCode']);

Create Controller By Artisan

Now, you need to generate or create a controller file using php artisan command, so use the php artisan make:controller command and generate/create a new controller file:

php artisan make:controller GenerateQrCodeController

We will create some methods in this controller file. This method will generate or create simple QR code, color QR code, and image QR code.

After that, go to App/Http/Controllers/ directory and find the created GenerateQrCodeController  file and update the following code into your file:

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator,Redirect,Response;
class GenerateQrCodeController extends Controller
    public function simpleQrCode() 

      \QrCode::size(300)->generate('A basic example of QR code!');

    public function colorQrCode() 

     return \QrCode::size(300)
             ->generate('A simple example of QR code');
    public function imageQrCode() 

      $image = \QrCode::format('png')
               ->merge('images/laravel.png', 0.5, true)
               ->generate('A simple example of QR code!');
      return response($image)->header('Content-type','image/png');


Start development server

You can use the following command artisan command to start the development server:

php artisan serve

The final step, go to your browser and type the below-given URL into your browser:





This tutorial idea has taken from the following urls: