peal / qrcode-generator
QR code generate in Laravel
Requires
- laravel/framework: 5.2.*|5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.*|10.*|11.*
This package is auto-updated.
Last update: 2024-10-31 00:21:28 UTC
README
A QR code (quick response code) is a type of 2D bar code that is used to provide easy access to information through a smartphone. In this process, known as mobile tagging, the smartphone's owner points the phone at a QR code and opens a barcode reader app which works in conjunction with the phone's camera.
Installation
Inside your project root directory, open your terminal
composer require peal/qrcode-generator
Composer will automatically download all dependencies.
For Laravel
After complete the installation, open your app.php from config folder, paste below line inside providers array
peal\qrcodegenerator\QrServiceProvider::class,
For Facade support, paste below line inside aliases array
'QR' => peal\qrcodegenerator\Facades\QR::class,
Then run this command
php artisan vendor:publish --provider="peal\qrcodegenerator\QrServiceProvider"
After vendor published check your config folder qr-config.php is created.
/* * QR api url * */ return [ 'qrapi' => 'https://chart.googleapis.com/chart?', ];
SINGLE QR CODE USAGES
//Using Facades try { $qrcontent = QR::qrFactory() ->email("moinuddin7@gmail.com") ->phone("01716187302") ->url("https://moinshareidea.wordpress.com/") ->text("position:","Lead Developer at GrubDealz Inc.") ->QrCode(200); echo '<p class="center"><img src="' . $qrcontent . '" alt="QR Code" /></p>'; } catch(Exception $e) { return $e->getMessage(); } //Using service container try { $qr = App::make('QR'); $qrcontent = $qr->qrFactory() ->email("moinuddin7@gmail.com") ->phone("01716187302") ->text("website:","https://moinshareidea.wordpress.com/") ->text("position:","Lead Developer at GrubDealz Inc.") ->QrCode(200); echo '<p class="center"><img src="' . $qrcontent . '" alt="QR Code" /></p>'; } catch(Exception $e) { return $e->getMessage(); } //Using core PHP try { //Without Laravel, can be usable any php or php framework $qr = new \peal\qrcodegenerator\Server\QrServer(); $qrcontent = $qr->qrFactory() ->email("moinuddin7@gmail.com") ->phone("01716187302") ->text("website:","https://moinshareidea.wordpress.com/") ->text("position:","Lead Developer at GrubDealz Inc.") ->QrCode(200); echo '<p class="center"><img src="' . $qrcontent . '" alt="QR Code" /></p>'; } catch(Exception $e) { return $e->getMessage(); }
Multiple QR code using Facades
//in your controller contruct method $qr = App::make('QR'); try { $qrcodes = [ [ 'email' => 'moinuddin7@gmail.com', 'phone' => '01716187302', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Lead Developer at GrubDealz Inc.', ], [ 'email' => 'moinuddinbca7@gmail.com', 'phone' => '01716187332', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Software engineer at GrubDealz Inc.', ], [ 'email' => 'arifinbca@gmail.com', 'phone' => '01716187392', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Business development officer at BCA Bangladesh.', ], ]; foreach($qrcodes as $qrcode) { $qrcontent = $qr->qrFactory() ->email($qrcode['email']) ->phone($qrcode['phone']) ->url($qrcode['url']) ->text('',$qrcode['position']) ->QrCode(200); echo '<p class="center"><img src="' . $qrcontent . '" alt="QR Code" /></p>'; } } catch(Exception $e) { return $e->getMessage(); }
Multiple QR Code using Core PHP
use peal\qrcodegenerator\Server\QrServer; $qr = new QrServer(); try { $qrcodes = [ [ 'email' => 'moinuddin7@gmail.com', 'phone' => '01716187302', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Lead Developer at GrubDealz Inc.', ], [ 'email' => 'moinuddinbca7@gmail.com', 'phone' => '01716187332', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Software engineer at GrubDealz Inc.', ], [ 'email' => 'arifinbca@gmail.com', 'phone' => '01716187392', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Business development officer at BCA Bangladesh.', ], ]; foreach($qrcodes as $qrcode) { $qrcontent = $qr->qrFactory() ->email($qrcode['email']) ->phone($qrcode['phone']) ->url($qrcode['url']) ->text('',$qrcode['position']) ->QrCode(200); echo '<p class="center"><img src="' . $qrcontent . '" alt="QR Code" /></p>'; } } catch(Exception $e) { return $e->getMessage(); }
Multiple QR code using Facades
use peal\qrcodegenerator\Facades\QR; try { $qrcodes = [ [ 'email' => 'moinuddin7@gmail.com', 'phone' => '01716187302', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Lead Developer at GrubDealz Inc.', ], [ 'email' => 'moinuddinbca7@gmail.com', 'phone' => '01716187332', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Software engineer at GrubDealz Inc.', ], [ 'email' => 'arifinbca@gmail.com', 'phone' => '01716187392', 'url' => 'https://moinshareidea.wordpress.com/', 'position' => 'Business development officer at BCA Bangladesh.', ], ]; foreach($qrcodes as $qrcode) { $qrcontent = QR::qrFactory() ->email($qrcode['email']) ->phone($qrcode['phone']) ->url($qrcode['url']) ->text('',$qrcode['position']) ->QrCode(200); echo '<p class="center"><img src="' . $qrcontent . '" alt="QR Code" /></p>'; } } catch(Exception $e) { return $e->getMessage(); }