zhangchunsheng / php-qrcode
php qrcode is qrcode utils written in PHP.
Requires
- php: ^7.0 || ^8.0
This package is auto-updated.
Last update: 2024-11-22 00:12:30 UTC
README
This is PHP 7+ only implementation of QR Code 2-D barcode generator.
Based on:
http://sourceforge.net/projects/phpqrcode/
By Dominik Dzienia
I was looking for a QR implementation for the pChart fork and came across this one.
It was either refactor Dominik's or use Chillerlan's (https://github.com/chillerlan/php-qrcode)
This fork is not a drop in replacement.
My code is four times smaller and two times faster
(much much faster than the Chillerlan's implementation)
Usage:
Possible hints: "Numeric", "Alphanumeric", "Byte", "Kanji"
- Single line:
(new QRCode([
'level' => $error_correction_level,
'size' => $max_module_size,
'margin' => $white_frame_size
]))->encode('https://github.com/zhangchunsheng/php-qrcode')->toFile("example.QRcode.png");
-
Or:
$QRCode = new QRCode(['level' => "Q", 'size' => 10, 'margin' => 4]);
$QRCode->encode('https://github.com/zhangchunsheng/php-qrcode', $hint); -
Dump the matrix:
echo json_encode($QRCode->toArray()); -
Load a matrix:
$QRCode->fromArray($matix); -
Dump base64 encoded PNG:
$QRCode->toBase64(); -
Create ASCII:
$QRCode->toASCII(); -
Output to file:
$QRCode->toFile("example.QRcode.png");
$QRCode->toFile("example.QRcode.svg");
$QRCode->toFile("example.QRcode.jpg"); -
Add HTTP headers:
$QRCode->forWeb("PNG");
$QRCode->forWeb("SVG");
$QRCode->forWeb("JPG", $quality = 90);