zhangchunsheng / php-qrcode
php qrcode是用PHP编写的二维码工具。
Requires
- php: ^7.0 || ^8.0
This package is auto-updated.
Last update: 2024-09-21 23:53:09 UTC
README
这是仅适用于PHP 7+的QR码2D条码生成器的实现。
基于
http://sourceforge.net/projects/phpqrcode/
由Dominik Dzienia编写
我在寻找pChart分支的QR实现时发现了这个。
要么重构Dominik的,要么使用Chillerlan的(https://github.com/chillerlan/php-qrcode)
这个分支不是直接替换。
我的代码体积小四倍,速度快两倍
(比Chillerlan的实现快得多)
用法
Possible hints: "Numeric", "Alphanumeric", "Byte", "Kanji"
- 单行
(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");
-
或者
$QRCode = new QRCode(['level' => "Q", 'size' => 10, 'margin' => 4]);
$QRCode->encode('https://github.com/zhangchunsheng/php-qrcode', $hint); -
输出矩阵
echo json_encode($QRCode->toArray()); -
加载矩阵
$QRCode->fromArray($matix); -
输出base64编码的PNG
$QRCode->toBase64(); -
创建ASCII
$QRCode->toASCII(); -
输出到文件
$QRCode->toFile("example.QRcode.png");
$QRCode->toFile("example.QRcode.svg");
$QRCode->toFile("example.QRcode.jpg"); -
添加HTTP头
$QRCode->forWeb("PNG");
$QRCode->forWeb("SVG");
$QRCode->forWeb("JPG", $quality = 90);