Laravel 6 Simple Generator or Create Qr Code Example

In this laravel 6 generate QR code example. We would love to share with you how to generate (create) QR code using simple-QRcode in laravel projects. You can simply create (generate) QR codes with text, size, color, background color, format like png, eps, SVG.

simple-QRcode is a composer package to generate QR code in your laravel application. In this example we will show you how you can send SMS and email of generated QR code, You can also create QR code for geo, phone number, text message using a simple QRcode package.

Simple QR codes package is very easy to install and use. Simple QR code package has provided many functions (options) for creating (generating) QR codes. In this example, we will learn how to use this package and generate QR codes.

Generate QR codes in Laravel

Follow the below steps and easily create or generate QR codes in laravel Projects.

  • Install Laravel Fresh Setup
  • Set database Credentials In .env File
  • Install simple-QRcode Package
  • Register Package
  • Test Qr Code
  • Conclusion

1. Install Laravel Fresh Project

We need to install Laravel fresh application setup using below command, Open your command prompt and run the below command :

composer create-project --prefer-dist laravel/laravel Laravel-QR-Code

2. Set database Credentials In .env File

Next step, you have downloaded the fresh new setup of laravel in your system. So set the database credentials in your application. Let’s open your project .env file and set the database credentials here.

DB_DATABASE=here your database name here
DB_USERNAME=here database username here
DB_PASSWORD=here database password here

3. Install simple-QRcode Package

In this step, we will install a simple-QRcode package for the QR code generator, go to terminal and use the below command for install QR code package in laravel based application.

composer require simplesoftwareio/simple-qrcode

4. Register Package

After successfully install a simple QR code package in the laravel app. Next, open config/app.php file and add service provider and aliases.


'providers' => [

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

5. Test Qr Code

Now we will generate and test qr code in laravel application.

Simple Qr code :

We will add a route and return QR code. Simply add the following code in your web.php file.

Route::get('qrcode', function () {
return QrCode::size(300)->generate('A basic example of QR code!');

size() function is used to specify the size of QR. When we hit the route /QRcode, we get the QR code as below :

php qr code
QR Code with Color :

Now We can change the color of QR code. Go to route web.php file and specify this route.

Route::get('qrcode-with-color', function () {
return \QrCode::size(300)
->generate('A simple example of QR code');

The above code output a QR code shown below :

color qr code
QR Code with Image :

We will also place an image inside the QR code. Go to route web.php file and specify this route.

Route::get('qrcode-with-image', function () {
$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');

The above code output a QR code as shown below :

image qr code
Email QR code :

We can also automatically fill email, subject, and body when scanned.

Route::get('qrcode-with-special-data', function() {
return \QrCode::size(500)
->email('[email protected]', 'Welcome to Tutsmake!', 'This is !.');
QR Code Phone Number :

This package also helps to dial a number when QR code is scanned.

QR Code Text Message

We can prefilled phone number and text messages when scanned the QR code.

QrCode::SMS('111-222-6666', 'Body of the message');


In this laravel simple QR code tutorial – we have successfully installed and configure a simple QR code package in laravel application. We have also learned how to create (generate) simple QR code in laravel application with send SMS text and email to QR code.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *