Search code examples
phpsvgqr-code

Error generating SVG with phpqrcode


I am trying to execute following code from the SVG basic output example from the docs.

<?php
include('vendors/phpqrcode/qrlib.php');
$svgCode = QRcode::svg('PHP QR Code :)');
echo $svgCode; 

All I get is the error:

Fatal error: Call to undefined method QRcode::svg()

/path/to/php/file/index.php on line 1337

The strange thing is that the simple PNG output example works fine without any errors, so the include must be correct.

<?php
include('vendors/phpqrcode/qrlib.php');
QRcode::png('PHP QR Code :)');

Do you guys have an idea what I might have forgot to check? Maybe the error is obvious for you.


Solution

  • As noticed in another thread and I experienced myself, the latest version is at https://github.com/t0k4rt/phpqrcode. With the version there, SVG is implemented and working.