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.
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=database_name DB_USERNAME=database_user_name DB_PASSWORD=database_password
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:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use QrCode;
class QRCodeController extends Controller
{
public function index()
{
return view('qr_code');
}
}Step 4 : Add Route
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 5: Generate QR Codes in Blade View
Let’s create a qr_code blade file and added the below code into this file.
<title>Laravel 8 QR Code Generator Example - phpflow.cc</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-dwsdwdw" crossorigin="anonymous">
<div class="container">
<div class="row text-center mt-5">
<div class="col-md-6">
<h4>Simple QR Code Example</h4>
{!! QrCode::size(150)->generate('phpflow.cc') !!}
</div>
<div class="col-md-6">
<h4>Color Qr Code</h4>
{!! QrCode::size(150)->backgroundColor(255,55,0)->generate('phpflow.cc') !!}
</div>
</div>
</div>Step 6: Run Laravel Application
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.

















