primer / phpqrcode
A modern implementaion of QR code 2D barcode generator. Pure-php LGPL implementation based on https://phpqrcode.sourceforge.net, itself based on C libqrencode by Kentaro Fukuchi.
1.2.1
2026-08-03 19:03 UTC
Requires
- php: >=7.3
- ext-gd: *
- ext-zlib: *
Requires (Dev)
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ~8.5.0
- thiagolp90/qr-reader: ~1
README
PHP QRCode Generator Library for php 7.3 and later.
A modern implementaion of QR code 2D barcode generator. Pure-php LGPL implementation based on inital phpqrcode, itself based on C libqrencode.
Installation
Type on the terminal
composer require primer/phpqrcode
Or, by adding this entry on the composer.json file
{
"require": {
"primer/phpqrcode": "~1"
}
}
Usage
Encode "data" into a png file:
QRcode::png("data", "path/to/file.png");
Options
QRcode::png($text, $outfile , correctionLevel: QRConstants::QR_ECLEVEL_L, size: 3, margin: 4, saveandprint: false);
Correction Level
(int) correction level, fom the lowest to highest:
QRConstants::QR_ECLEVEL_L0QRConstants::QR_ECLEVEL_M1QRConstants::QR_ECLEVEL_Q2QRConstants::QR_ECLEVEL_H3
Size
(int) Pixel size
Margin
(int) Raw silent zone (margin zone = raw * size)
Save and Print
(bool) Use saveAndPrint (bool) option to send to the browser both http header and image content.
Credits
- Kentaro Fukuchi: for inital libqrencode C Lib (kentaro@megaui.net)
- Dominik Dzienia: for https://phpqrcode.sourceforge.net (deltalab@poczta.fm)
