How To Generate QR code in laravel 8 — Phpflow.com

Parvez Alam
2 min readFeb 6, 2022

In this article, we’ll look at an example of a laravel 8 QR code generator. we’ll use the simplesoftwareio/simple-qrcode package to generate QR codes. That helps to generate qr code. You may generate a simple QR code, text QR code, or image QR code in Laravel 8.

The simplesoftwareio/simple-qrcode package is a simple PHP QR Code generator with Laravel 8 compatibility. You can also adjust the color, size, text, height, and width to meet your needs.

How To Integrate QR Code Generator With Example

Let’s create a Laravel project and install dependencies to integrate qr code generator functionality.

Configure Database

We will set up database configuration in the .env file.

Step 1 : Create Laravel 8 Project
Let’s create a laravel 8 project using the below command.
composer create-project --prefer-dist laravel/laravel laravel_8_qr_code_example

Step 2 : Install QR Code Package
Now, We will install simplesoftwareio/simple-qrcode package using the below command.

composer require simplesoftwareio/simple-qrcode

Step 3 : Create Controller
We have created laravel project and installed qr package, Let’s create a QRCodeController using the below command.

php artisan make:controller QRCodeController

Added the below code into the above file:

Step 4 : Add Route
we will add the qr-code route in the web.php file.

Step 5 : Generate QR Codes in Blade View
create a qr_code blade file and added the below code into the this file.

Step 6 : Run Laravel App
Now, run the laravel project using the below command.

php artisan serve

open the below URL on your browser.

http://localhost:8000/qr-code

You can read more about simple-qrcode package from Official Documentation.

Originally published at https://www.phpflow.com on February 6, 2022.

--

--

Parvez Alam

Hey, I am Parvez Alam. A software developer since 2009. I love learning and sharing knowledge. https://www.phpflow.com/