Friday, February 14, 2020

Laravel 6 QR Code Generator

Laravel 6 QR Code Generator

If you want to see an example of a Laravel 6 QR code generator. This publication gives you a simple example of a Laravel 6 QR code example. We'll help you give an example of creating QR code in Laravel 6. I simply explained step by step how to create a QR code in Laravel 6. So, follow a few steps to create an example of QR code generation in Laravel 6.

simple-qrcode is a composer package for generating qr code in your Laravel 6 application. simple-qrcode enables SMS and emails to be sent with the generated qr code. With the simple QR code package you can create QR code for geo, phone number and date of birth.

After generating the qr code, we may need to write code for the scan code using jquery. If you have the same requirements to scan qr code with jquery, you can follow my tutorial: qr code scanner with instascan js.

Here I am writing a step-by-step example to generate qr code in your Laravel 5 management area. So follow a few steps to get this example:

Step 1: Install Laravel 6


In first step, If you haven't installed laravel 6 in your system then you can run bellow command and get fresh Laravel project.

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

Step 2: Install simple-qrcode Package


Now we need to install the simple qrcode package for the qr code generator so that we can use its method. Then open your terminal and run the following command.

composer require simplesoftwareio/simple-qrcode
Now open config/app.php file and add service provider and aliase.

config/app.php

'providers' => [

....

SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class

],

'aliases' => [

....

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

],


Step 3: Create Route


In this step we create a route for the test example. So let's add a new path to this file.
routes/web.php

<?php



Route::get('qr-code-g', function () {

  

    \QrCode::size(500)

            ->format('png')

            ->generate('myitbuddies.com', public_path('images/qrcode.png'));

    

  return view('qrCode');

    

});


Step 4: Create Blade file


Now we have to create qrCode.blade.php to display the qr code. So let's create a blade file like the following code:

resources/views/qrCode.blade.php

<!DOCTYPE html>

<html>

<head>

    <title>Laravel 6 QR code generator - myitbuddies.com</title>
</head>

<body>

    

<div class="visible-print text-center">

    <h1>Laravel 6 - QR Code Generator Example</h1>

     

    {!! QrCode::size(250)->generate('myitbuddies.com'); !!}

     

    <p>example by myitbuddies.com.</p>
</div>

    

</body>

</html>


Now you can run and check it.
I hope This Could help you...


0 comments:

Post a Comment

Please don't enter any spam link in the comment box.