Not sure if it's what you're after, but https://github.com/tecnickcom/TCPDF can generate QR-codes, barcodes etc.
QR Code Generator
I was wondering if there is a laravel library to generate QR Codes?
Not laravel specific, but this is the most popular (by huge margin) composer package for QR generation with php: https://packagist.org/packages/bacon/bacon-qr-code
The package @ohffs linked to is more popular, but also does a lot more. If you're only interested in QR it might be overkill -- it also looks like it's only for PDFs, which probably won't help if you just need to place the QR code somewhere and have no use for PDF generation. :)
A lot of that generates PDFs with the content in it. I am looking for something that generates the image QR code.
In my projects I decided to use google api instead: http://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=helloworld
It's fast and reliable.
@sl0wik That one is now deprecated
Hello friends , here is the PHP laravel integration for QR-CODE Login , My article How to integrate on your project : http://www.rolandalla.com/laravel-login-qr-code/ My github full project: https://github.com/roladn/laravel-qr-code-login
Now there is!
This is very much easier to use...
https://www.kerneldev.com/2018/09/07/qr-codes-in-laravel-complete-guide/
composer require simplesoftwareio/simple-qrcode
@BRUNOWERNECK - Broken link
@BRUNOWERNECK - URL doesn't work
@qljsystems Yeah, the maintainer either closed or moved the repo with that QR package since that link was posted over year ago. Not sure what brunowerneck can do about that.
@brunowerneck the links broken. cant be found on git repo.
https://itsolutionstuff.com/post/laravel-57-qr-code-generator-exampleexample.html try this its working
I downloaded qrcode with this=> ' composer require simplesoftwareio/simple-qrcode' trying to use the QrCode in the controller i am getting the error => badmethodcallexception. the error is pointing at the QrCode. i really need help on this as i have been going back and forth for hours
*
* @return Response
*/
public function store(CreateQrcodeRequest $request)
{
$input = $request->all();
//save data to database
$qrcode = $this->qrcodeRepository->create($input);
//generate qrcodes
//save qrcode image in our folder on this site
$file = 'generated_qrcodes/'.$qrcode->id.'.png';
$newqrcode = QrCode::text('message')
->setSize(4)
->setMargin(2)
->setOutfile($file)
->generate('ItSolutionStuff.com')
->png();
if( $newqrcode){
$input['qrcode_path'] = $file;
// //update database
QrCode::where('id', $qrcode->id)
->update([
'qrcode_path' => $input['qrcode_path']
]);
@VANDAN - sir, the qrcode did not work. its telling me QrCode class is not existing.
@SHIPMENT12 - show me error can you please more expicit to what you achive?
@VAN1310 - this is my QrCodecontroller
namespace App\Http\Controllers;
use App\Http\Requests\CreateQrcodeRequest;
use App\Http\Requests\UpdateQrcodeRequest;
use App\Repositories\QrcodeRepository;
use App\Http\Controllers\AppBaseController;
use Illuminate\Http\Request;
use Flash;
use Auth;
use QrCode;
use BaconQrCode;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
class QrcodeController extends AppBaseController
{
/** @var QrcodeRepository */
private $qrcodeRepository;
public function __construct(QrcodeRepository $qrcodeRepo)
{
$this->qrcodeRepository = $qrcodeRepo;
}
/**
* Display a listing of the Qrcode.
*
* @param Request $request
* @return Response
*/
public function index(Request $request)
{
$this->qrcodeRepository->pushCriteria(new RequestCriteria($request));
$qrcodes = $this->qrcodeRepository->all();
return view('qrcodes.index')
->with('qrcodes', $qrcodes);
}
/**
* Show the form for creating a new Qrcode.
*
* @return Response
*/
public function create()
{
return view('qrcodes.create');
}
/**
* Store a newly created Qrcode in storage.
*
* @param CreateQrcodeRequest $request
*
* @return Response
*/
public function store(CreateQrcodeRequest $request)
{
$input = $request->all();
//save data to database
$qrcode = $this->qrcodeRepository->create($input);
//generate qrcodes
//save qrcode image in our folder on this site
$file = 'generated_qrcodes/'.$qrcode->id.'.png';
$newqrcode = QrCode::text('message')
->setSize(4)
->setMargin(2)
->setOutfile($file)
->png();
if( $newqrcode){
$input['qrcode_path'] = $file;
// //update database
$newqrcode = QrCodeModel::where('id', $qrcode->id)
->update([
'qrcode_path' => $input['qrcode_path']
]);
}else{
Flash::success('Qrcode saved successfully.');
}
Flash::error('Qrcode unsuccessfully saved.');
return redirect(route('qrcodes.index'));
}
/**
* Display the specified Qrcode.
*
* @param int $id
*
* @return Response
*/ ```
@VAN1310 - this is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"appointer/swaggervel": "dev-master",
"bacon/bacon-qr-code": "^1.0",
"doctrine/dbal": "~2.3",
"fideloper/proxy": "^4.0",
"infyomlabs/adminlte-templates": "5.6.x-dev",
"infyomlabs/laravel-generator": "5.6.x-dev",
"infyomlabs/swagger-generator": "dev-master",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.6.0",
"simplesoftwareio/simple-qrcode": "^2.0"
},
"require-dev": {
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
this is the error i am getting
C:\xampp\htdoz\qrcode\vendor\simplesoftwareio\simple-qrcode\src\SimpleSoftwareIO\QrCode\BaconQrCodeGenerator.php
$dataType = $this->createClass($method);
$dataType->create($arguments);
return $this->generate(strval($dataType));
}
/**
* Creates a new DataType class dynamically.
*
* @param string $method
*
* @return SimpleSoftwareIO\QrCode\DataTypes\DataTypeInterface
*/
private function createClass($method)
{
$class = $this->formatClass($method);
if (!class_exists($class)) {
throw new \BadMethodCallException();
}
return new $class();
}
/**
* Formats the method name correctly.
*
* @param $method
*
* @return string
*/
private function formatClass($method)
{
$method = ucfirst($method);
$class = "SimpleSoftwareIO\QrCode\DataTypes\".$method;
return $class;
}
Arguments
""
'
@VAN1310 - more errors
BadMethodCallException
No message
C:\xampp\htdoz\qrcode\app\Http\Controllers\QrcodeController.php
*
* @return Response
*/
public function store(CreateQrcodeRequest $request)
{
$input = $request->all();
//save data to database
$qrcode = $this->qrcodeRepository->create($input);
//generate qrcodes
//save qrcode image in our folder on this site
$file = 'generated_qrcodes/'.$qrcode->id.'.png';
$newqrcode = QrCode::text('message')
->setSize(4)
->setMargin(2)
->setOutfile($file)
->png();
if( $newqrcode){
$input['qrcode_path'] = $file;
// //update database
$newqrcode = QrCodeModel::where('id', $qrcode->id)
->update([
'qrcode_path' => $input['qrcode_path']
]);
}else{
Flash::success('Qrcode saved successfully.');
}
Flash::error('Qrcode unsuccessfully saved.');
Arguments
"text"
array:1 [▶]
@VAN1310 - ```
GET Data empty POST Data _token "P5YEFVJooeUBGFai2TobaUuukcSPzDpKXxwotObe" user_id "1" website "faceboo.com" product_name "great" product_url "fried rice" company_name "wenick" callback_url "www.facebook/udediborfavour" amount "1200" status "1" Files empty Cookies remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d "eyJpdiI6Ik13cEpIaEZlalRjcFhXYUpWczBoaGc9PSIsInZhbHVlIjoiNWJ0MllReWRNQVA5bWQreHU1YjN1KzdtTmZ3MFlISWVsWHUrVDNcL2N2citSbTA3YW9YUEFtNDdPRlhYak9pXC96OXlMeCtnVDRpMCtm ▶" XSRF-TOKEN "eyJpdiI6IjNYWU1FZ1NyVUVtRXpOaUNkd0lNZ0E9PSIsInZhbHVlIjoiXC93RFo0STlNXC9UaGtrT3RwU3ZCKzlma0hEOStFcllRWXBYQ0diZTQ4YzhQaGRxdStCQ0pBeEZmdTlwYkx5K2VPIiwibWFjIjoiY2Jj ▶" laravel_session "eyJpdiI6ImNid0pqMkVmODlFYjBNd0hWUkZIQUE9PSIsInZhbHVlIjoieXFSTlZMSXVBMFRleWZsXC9zdTN6VnNpQU1yZHBtaDk0a0Ixb1FRcVJXam1tbW1RZDBOWVdRVnpZeU1uc1ZkcmciLCJtYWMiOiJkYTUz ▶" Session empty Server/Request Data DOCUMENT_ROOT "C:\xampp\htdoz\qrcode\public" REMOTE_ADDR "127.0.0.1" REMOTE_PORT "50774" SERVER_SOFTWARE "PHP 7.2.17 Development Server" SERVER_PROTOCOL "HTTP/1.1" SERVER_NAME "127.0.0.1" SERVER_PORT "8000" REQUEST_URI "/qrcodes" REQUEST_METHOD "POST" SCRIPT_NAME "/index.php" SCRIPT_FILENAME "C:\xampp\htdoz\qrcode\public\index.php" PATH_INFO "/qrcodes" PHP_SELF "/index.php/qrcodes" HTTP_HOST "127.0.0.1:8000" HTTP_CONNECTION "keep-alive" CONTENT_LENGTH "212" HTTP_CONTENT_LENGTH "212" HTTP_CACHE_CONTROL "max-age=0" HTTP_ORIGIN "http://127.0.0.1:8000" HTTP_UPGRADE_INSECURE_REQUESTS "1" CONTENT_TYPE "application/x-www-form-urlencoded" HTTP_CONTENT_TYPE "application/x-www-form-urlencoded" HTTP_USER_AGENT "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" HTTP_ACCEPT "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3" HTTP_REFERER "http://127.0.0.1:8000/qrcodes/create" HTTP_ACCEPT_ENCODING "gzip, deflate, br" HTTP_ACCEPT_LANGUAGE "en-US,en;q=0.9" HTTP_COOKIE "remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=eyJpdiI6Ik13cEpIaEZlalRjcFhXYUpWczBoaGc9PSIsInZhbHVlIjoiNWJ0MllReWRNQVA5bWQreHU1YjN1KzdtTmZ3MFlISWVsWHUrVD ▶" REQUEST_TIME_FLOAT 1556184289.6543 REQUEST_TIME 1556184289 Environment Variables empty Registered Handlers
- Whoops\Handler\PrettyPageHandler
I don't know if you want a complex QR code with background images, or alternative colors ... but as long as all you want is a simple black on white QR Code ... and you don't need it to be larger than 547pixels by 547 pixels ... then you can do it all with one simple call to the Google API.
The old Google Chart Api was depreciated ... but the Infographics Api is still available
To create a QR Code with the text "QR Code for Laracasts" in a size of 500 pixels by 500 pixels you just need the folloing URI
https://chart.googleapis.com/chart?chs=500x500&cht=qr&chl=QR%20Code%20for%20Laracasts
You can view the documentation at
https://developers.google.com/chart/infographics/docs/overview
use this package : simplesoftwareio/simple-qrcode and save image :
$fileNameCodeUnique = md5(time()); $qrcode = QrCode::size(512) ->format('svg') ->generate($request->code, base_path() . '/storage/app/public/qrproducts/qrcodes/' . $fileNameCodeUnique . '.svg');
@saeed410 I agree, this package is sweet https://github.com/SimpleSoftwareIO/simple-qrcode
Please or to participate in this conversation.