endroid / qr-code

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

Message: Call to undefined method Endroid\QrCode\QrCode::getMimeType() #329

Closed gagaltotal closed 3 years ago

gagaltotal commented 3 years ago

please help me

why error method Endroid\QrCode\QrCode::getMimeType() ? and me use latest version endroid/qr-code 4.0....

i use codeigniter 3.1.11 on PHP version 7.4 composer version 2.1.3

my template in view, tested qrcode

$qrcode = new Endroid\QrCode\QrCode('tester');

header('Content-Type: '.$qrcode->getMimeType());
echo $qrcode->getString();
An uncaught Exception was encountered
Type: Error
Message: Call to undefined method Endroid\QrCode\QrCode::getMimeType()

is my method wrong from the example in the readme ?

endroid commented 3 years ago

Hi @gagaltotal as you can see in the readme for 4.x you should use $result->getMimeType(); Good luck!

gagaltotal commented 3 years ago

I've used this method $result->getMimeType(); still the error is like that why ?

gagaltotal commented 3 years ago

when I use this method from Readme

use Endroid\QrCode\QrCode;
use Endroid\QrCode\Writer\PngWriter;

$writer = new PngWriter();

// Create QR code
$qrCode = QrCode::create('tester');

$result = $writer->write($qrCode);

header('Content-Type: '.$result->getMimeType());
echo $result->getString();

the result is only a small box

https://imgur.com/v4Cp2kq

SOLVED METHOD..

endroid commented 3 years ago

The small box indicates your image can not be rendered, probably because of an error. You can comment the header line to not output as an image, so you can see what's wrong.

gagaltotal commented 3 years ago

okay thanks, solved