Generate QR Code Laravel 8 Example

Share this Article
Reading Time: 4 minutes

Inside this article we will learn to generate QR code in Laravel 8. There are very basics to create QR code in laravel 8. QR code generate with the help of composer package in Laravel 8.

A QR code is a type of matrix barcode invented in 1994 by the Japanese automotive company Denso Wave. A barcode is a machine-readable optical label that contains information about the item to which it is attached.

Learn More –

Let’s get started.

Installation of Laravel Application

Laravel Installation can be done in two ways.

  • Laravel Installer
  • By using composer

Laravel Installer

To install Laravel via Laravel installer, we need to install it’s installer first. We need to make use of composer for that.

$ composer global require laravel/installer

This command will install laravel installer at system. This installation is at global scope, so you type command from any directory at terminal. To verify type the given command –

$ laravel

This command will open a command palette of Laravel Installer.

To create ad install laravel project in system,

$ laravel new blog

With the name of blog a laravel project will be created at your specified path.

By using composer

Alternatively, we can also install Laravel by Composer command create-project.

If your system doesn’t has composer Installed, Learn Composer Installation Steps.

Here is the complete command to create a laravel project-

$ composer create-project --prefer-dist laravel/laravel blog

After following these steps we can install a Laravel application into system.

To start the development server of Laravel –

$ php artisan serve

This command outputs –

Starting Laravel development server:

Assuming laravel already installed at system.

Install simple-qrcode Package

There are several composer packages available which provides support for QR Code. So here by using simple-qrcode Package, we will see working with QR code in Laravel 8.

More about package, here is the link you can find Click here.

Go to your project terminal and install this package.

$ composer require simplesoftwareio/simple-qrcode

When you install this is the screen you should get.

Now open /config/app.php file and add service providers and aliases.

# Add this to providers array
'providers' => [


# Add this to aliases array
'aliases' => [
    'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class

Configure Application Route

Let’s create a route.

Open up the file /routes/web.php

use SimpleSoftwareIO\QrCode\Facades\QrCode;

Route::get('generate-qr-code', function () {
            ->generate('Online Web Tutor', public_path('images/owt.png'));
  return view('generate-qr-code');
  • Import this package to web.php file use SimpleSoftwareIO\QrCode\Facades\QrCode;
  • Using QrCode Methods to generate QR code.
  • Generated QR code code will be saved inside /public/images/ directory with the name owt.png.

Create Blade Template File

While creating route we have called generate-qr-code template. So we need to create generate-qr-code.blade.php file inside /resources/views

Open up the blade template file write this following piece of code.

<!DOCTYPE html>
    <title>How to Generate QR Code in Laravel 8 - Online Web Tutor</title>
          text-align: center;
<div class="visible-print text-center">
    <h1>Laravel 8 - QR Code Generator Example</h1>
    {!! QrCode::size(250)->generate('Online Web Tutor'); !!}
    <p>Simple Basic Example by</p>

Application Testing

Open project to terminal and type the command to start development server

$ php artisan serve


We hope this article helped you to learn about Generate QR Code Laravel 8 in a very detailed way.

Buy Me a Coffee

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Find More on Laravel 8 Articles here

2 thoughts on “Generate QR Code Laravel 8 Example”

  1. BaconQrCode\Exception\RuntimeException
    You need to install the imagick extension to use this back end

    Tanks for this tutorial.

    How can i resolve?

    • Hi, you need to run these commands if you are a linux user –
      1. Installation – sudo apt-get install php-imagick
      2. Verification – php -m | grep imagick
      3. Restart Apache – sudo service apache2 restart

Comments are closed.