How to generate QR Code in Laravel 8?

How to generate QR Code in Laravel 8?

How to generate QR Code in Laravel 8?

Today we are going to generate QR Code in Laravel 8. It's very simple, Let's go step by step.


Step 1

First step is to install a fresh Laravel 8 project and for that we need to run following command.

$ composer create-project laravel/laravel qrcode-generation

This will create a fresh Laravel project. Now after creating a fresh project let's open it in your favorite code editor. In my case i am going to open in Visual Studio Code.



Now it's time to move to next step.

Step 2

Let's install a package for QR Code generation that is developed to integrate with Laravel.

composer require simplesoftwareio/simple-qrcode

Above command is to install Simple QR Code package for your project. After installing this package do the following things.

Now open your web.php file and create a home route and import installed package and generate qrcode using below code.


use SimpleSoftwareIO\QrCode\Facades\QrCode;

Route::get('/', function () {
    return QrCode::size(250)->generate('youlinkgoeshere.com');
});



Step 3

Now run your server using command  php artisan serve and open http://127.0.0.1:8000 in your favorite browser. When you open this url you will see following output in your browser.





Hope this blog helped you to generate QR Code in Laravel 8. Thanks everyone.

Comments

Popular posts from this blog

How to generate barcode using Laravel 8?