php-qrcode-detector-decoder icon indicating copy to clipboard operation
php-qrcode-detector-decoder copied to clipboard

PHP 8, problem to Parse on QReader

Open Freepaq opened this issue 3 years ago • 16 comments

With PHP8, I have now an issue to decode QRCode :

Parse error: syntax error, unexpected fully qualified name "\Zxing\BinaryBitmap" expecting variable in qrcode-detector-decoder\lib\QrReader.php on line 15

Freepaq avatar Jun 30 '22 20:06 Freepaq

Might be related to (partially my fault, so sorry, as you will see) #123

GenieTim avatar Jul 01 '22 06:07 GenieTim

OK, do you will create a new release with a fix?

Freepaq avatar Jul 01 '22 07:07 Freepaq

I can only open a new PR asking the kind maintainer to publish as a major instead of a minor version and deleting the version he just published. I will do that somewhen on the weekend when I can actually provide some more value in the PR.

Your fix for now is to have composer require this library with version 1.0.5.2 (or upgrade to PHP 8.1).

GenieTim avatar Jul 01 '22 07:07 GenieTim

Hello,

Yes I have downgrade to previous version and it's working. Thanks

Have a good we

Le ven. 1 juil. 2022 à 09:30, Tim Bernhard @.***> a écrit :

I can only open a new PR asking the kind maintainer to publish as a major instead of a minor version and deleting the version he just published. I will do that somewhen on the weekend when I can actually provide some more value in the PR.

Your fix for now is to have composer require 1.0.5.2.

— Reply to this email directly, view it on GitHub https://github.com/khanamiryan/php-qrcode-detector-decoder/issues/126#issuecomment-1172032574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6Y3J7C7XHITIGZLP5UGFDVR2NCPANCNFSM52KUP6NQ . You are receiving this because you authored the thread.Message ID: @.***>

Freepaq avatar Jul 01 '22 08:07 Freepaq

Where can i download previous version, im not very familiar on github yet, wich version would be?

Monclee avatar Nov 17 '22 20:11 Monclee

on your project, you should hqve conposer:json file, just put on "require" array

"khanamiryan/qrcode-detector-decoder": "1.0.5.2"

1.0.5.2 is an example; the latest version is 2.0.2

Freepaq avatar Nov 17 '22 22:11 Freepaq

...and if you do not use composer, you find the releases (with source code) here: https://github.com/khanamiryan/php-qrcode-detector-decoder/releases

GenieTim avatar Nov 18 '22 07:11 GenieTim

Thanks that did it.

Monclee avatar Nov 19 '22 16:11 Monclee

Im converting a QR PDF to JPG and then to a string , it works great now.... I just found that if the PDF is sent via whatsapp, for some reason after that the process throw an empty text, (not finding qr anyone more), ¿does whatsapp affects pdfs?, i didnt know... Anyway is there any way to adjust de "sensibilty" or something like that? Sorry if this question is on the wrong place.

Monclee avatar Nov 19 '22 16:11 Monclee

Anyway is there any way to adjust de "sensibilty" or something like that?

Yes, there actually is (in the new version though):

you can use

$text = $qrcode->text([
'TRY_HARDER' => true
]);

for example. Other adjustments are also available, see for one example here, though be aware that these others require some fiddling with the numbers for your use case. Look at the library code where the options you pass are used, and what they accept.

I would recommend to either

  • cut your image better, such that it includes less stuff around, if you know where the QR-code is,
  • check the error, why no QR code is detected ($qrcode->getError()) and work from there
  • send a PR with such a failing PDF as a test (so devs know to fix this),
  • use a different QR-reader if this here fails.

GenieTim avatar Nov 20 '22 16:11 GenieTim

Hello

I have upgraded to 1.0.6 and then I have error

PHP Parse error: syntax error, unexpected fully qualified name "\Zxing\BinaryBitmap", expecting variable in /mnt/web115/a3/96/52045096/htdocs/AQB/vendor/khanamiryan/qrcode-detector-decoder/lib/QrReader.php on line 14

Freepaq avatar Nov 23 '22 07:11 Freepaq

Please upgrade to the latest version (2.0.2, seee https://github.com/khanamiryan/php-qrcode-detector-decoder/releases) if you have problems with an earlier one.

If you can't due to PHP incompatibilities, please downgrade to 1.0.5.2, 1.0.6 was removed, at least here on GitHub, since it should have been a major release.

GenieTim avatar Nov 23 '22 07:11 GenieTim

Hello with 1.0.5 I have this now : PHP Fatal error: Uncaught TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, bool given in /mnt/web115/a3/96/52045096/htdocs/AQB/vendor/khanamiryan/qrcode-detector-decoder/lib/QrReader.php:94 Stack trace: #0 /mnt/web115/a3/96/52045096/htdocs/AQB/vendor/khanamiryan/qrcode-detector-decoder/lib/QrReader.php(94): method_exists()

Freepaq avatar Nov 23 '22 08:11 Freepaq

Alright, you can now either catch this error and accept that it is equivalent to no text found, or upgrade to 1.0.5.2, it seems it was fixed there, see https://github.com/khanamiryan/php-qrcode-detector-decoder/compare/1.0.5...1.0.5.2

GenieTim avatar Nov 23 '22 08:11 GenieTim

Yes all is ok now. I will and a catch in case of. Thanks

Freepaq avatar Nov 23 '22 09:11 Freepaq

Ok im doing a log if errors come in. And im also adding this. Sice which version is this available?

$text = $qrcode->text([
'TRY_HARDER' => true
]);

Monclee avatar Nov 25 '22 20:11 Monclee