endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.46k stars 728 forks source link

setPadding function not working #272

Closed kamleshwebtech closed 4 years ago

kamleshwebtech commented 4 years ago

I am using your qr-code library and my code is as:

<?php
include('vendor/autoload.php');

use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\LabelAlignment;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\Response\QrCodeResponse;

$qrCode = new QrCode('Life is too short to be generating QR codes');
$qrCode->setSize(300);
$qrCode->setPadding(10);

header('Content-Type: '.$qrCode->getContentType());
echo $qrCode->writeString();

But when i run above code on local system, it generates a Fatal error:

Fatal error: Uncaught Error: Call to undefined method Endroid\QrCode\QrCode::setPadding() in D:\xampp\htdocs\sites\test\07-qrcode\index.php:13 Stack trace: #0 {main} thrown in D:\xampp\htdocs\sites\test\07-qrcode\index.php on line 13

line number 13 code is "header('Content-Type: '.$qrCode->getContentType());" as above code.

Please suggest what is the solution to fix this issue. Thanks a lot :)

Look forward to hear you.

endroid commented 4 years ago

Hi @kamleshwebtech the QrCode class does not have a setPadding method, only a setMargin. So you could use that.

adriangronau commented 3 years ago

I've run into the same issue after updating the package to 3.x. Looking back at version 1.x, the function setPadding did exist: https://github.com/endroid/qr-code/blob/c9644bec2a9cc9318e98d1437de3c628dcd1ef93/src/QrCode.php#L472

Is there some resource or further information about breaking changes between versions? Or a guide for migrating to a newer version?

endroid commented 3 years ago

Hi @tharkay unfortunately I did not have the time to write a migration guide so I think it is good to test your code thoroughly when upgrading. And if possible I would advise to upgrade to 4.x instead of 3.x because that is the currently maintained version.