KD2 Framework  QRCode

This library doesn't have any dependency.

It provides a quick, easy and efficient way of generating QR codes.

It supports only one mode: byte mode. The maximum string length allowed is 2,953 bytes at ECC level 1.


$qrcode = new \KD2\QRCode('Hello world!');
echo $qrcode->toSVG();

Supported exports

SVG is the best format for export, should you decide to use PNG for example, you can either convert the SVG using Imagemagick or use toArray() to get raw QR code data and build something with it.

  • QRCode->toSVG() exports as an SVG image
  • QRCode->toHTML() exports as an HTML table
  • QRCode->toCLI() exports as a Unicode text suitable for display in a terminal
  • QRCode->toArray() returns a bi-dimensional array (lines then columns) of raw data, each cell being set to either 0 or 1. Useful to export to other formats, like generating an image with Imagick or GD2.