endroid / qr-code

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

Show QRcode #297

Closed amskywalker closed 3 years ago

amskywalker commented 3 years ago

In version 8 of php, the QR code does not appear, only a white square appears.

Code

<?php

require __DIR__ . "/vendor/autoload.php";

use Endroid\QrCode\QrCode;

$qrCode = new QrCode('Life is too short to be generating QR codes');

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

echo $qrCode->writeString();

In version 7.4 this code work!!

Image

endroidtestphp8

chris97pl commented 3 years ago

It's most likely related to PHP8 issue (GD required). See this and next comment: https://www.php.net/manual/en/function.imagecreatetruecolor.php#125734

endroid commented 3 years ago

Hi @adailtonmoura if you uncomment the header line you can see the exact error message. Also the library has no PHP 8 support yet so I as mentioned above this will probably not work ;)

endroid commented 3 years ago

In the new 4.0.0 version which is PHP 8.0 compatible both resource and GdImage are supported.