In this post we will give you information about Laravel 5.7 – QR Code Generator Example. Hear we will give you detail about Laravel 5.7 – QR Code Generator ExampleAnd how to use it also give you demo for it if it is necessary.
simple-qrcode is a composer package for generate qr code in your laravel 5.7 application. simple-qrcode provide to send sms and email with generated qr code. you can create qr code for geo, phoneNumber, birthdate using simple qrcode package.
Here, i write example step by step to generate qr code in your laravel 5 admin panel. so let’s follow few steps to get this example:
Step 1: Install Laravel 5.7
In first step, If you haven’t installed laravel 5.7 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 require to install simple-qrcode package for qr code generator, that way we can use it’s method. So Open your terminal and run bellow command.
composer require simplesoftwareio/simple-qrcode "^2.0"
Now open config/app.php file and add service provider and aliase.
config/app.php
'providers' => [ .... SimpleQrCodeQrCodeServiceProvider::class ], 'aliases' => [ .... 'QrCode' => SimpleQrCodeQrCodeServiceProvider::class ],
Step 3: Create Route
In this step, we will create one route for testing example. So, let’s add new route on that file.
routes/web.php
<?php Route::get('qr-code-g', function () { QrCode::size(500) ->format('png') ->generate('pandasolutions.asia', public_path('images/qrcode.png')); return view('qrCode'); });
Step 4: Create Blade file
now we need to create qrCode.blade.php for display qr code. so let’s create blade file as like bellow code:
resources/views/qrCode.blade.php
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <div > <h1>Laravel 5.7 - QR Code Generator Example</h1> {!! QrCode::size(250)->generate('pandasolutions.asia'); !!} <p>example by pandasolutions.asia.</p> </div> </body> </html>
Now you can run and check it.
I hope it can help you…
Hope this code and post will helped you for implement Laravel 5.7 – QR Code Generator Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section.