Laravel PHP Simple Qr Codes Generate
Laravel 03-Oct-2020

Laravel PHP Simple Qr Codes Generate

In this laravel qr code tutorial, we will share with you how to generate (create) qr code using simple-qrcode in laravel 5.7 & 5.8. you can simply create (generate) qr codes with text, size, color, background color, format like png, eps, svg. This example also work with laravel version 5.8 , 5.7 & 5.6 .

simple-qrcode is a composer package for generate qr code in your laravel 5.7 application.In this example we will show you how to send sms and email with generated qr code, you can also create qr code for geo, phone number, text message using simple qrcode package.

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


  • Install Laravel Fresh Setup
  • Configuration .env file
  • Install simple-qrcode Package
  • Regiser Package
  • Test Qr Code
  • Conclusion

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 LaravelQR

Install simple-qrcode Package

In this step, we will install simple-qrcode package for 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

Register Package

After successfully install simple qr code package in laravel app. Next open config/app.php file and add service provider and aliase.


'providers' => [

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

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('', '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 install and configure simple qr code pakcage in laravel application. We have also learned how to create (generate) simple qr code in lara app with send sms text and email to qr code.