esyede/tiny-qrcode
最新稳定版本:v1.0.0
Composer 安装命令:
composer require esyede/tiny-qrcode
包简介
A tiny QRCode generator (single file, no dependencies)
README 文档
README
A tiny QR Code generator (single file, no dependencies)
Requirements:
- PHP 5.4 or newer
- PHP-GD exntension
Install
Via composer:
composer require esyede/tiny-qrcode
Manual install:
- Download the archive from the release page
- Extract the downloaded archive file
Load file
require 'vendor/autoload.php'; // via composer require 'path/to/TinyQRCode.php'; // manual
Display image
$data = 'https://github.com/esyede/tiny-qrcode'; $qr = new \Esyede\TinyQRCode\TinyQRCode($data); $qr->display();
Save image
$data = 'https://github.com/esyede/tiny-qrcode'; $qr = new \Esyede\TinyQRCode\TinyQRCode($data); $qr->store('path/to/store/qr.png');
Adjust QRCode options
Altering the error correction level
$data = 'https://github.com/esyede/tiny-qrcode'; $options = ['errorCorrectionLevel' => 'H']; $qr = new \Esyede\TinyQRCode\TinyQRCode($data, $options); $qr->display();
Available error correction levels:
| Code | Correction Level |
|---|---|
L |
7% |
M |
15% (default) |
Q |
25% |
H |
30% |
Changing the image size
The size of the generated QR image can be adjusted as follows. This does not affect error correction or similar.
$data = 'https://github.com/esyede/tiny-qrcode'; $options = ['imageSize' => 30]; $qr = new \Esyede\TinyQRCode\TinyQRCode($data, $options); $qr->display();
Changing the code version
The version of the QR code can be altered by passing options to the constructor. Note that in most cases this will result in an increase in image size.
$data = 'https://github.com/esyede/tiny-qrcode'; $options = ['version' => 5]; // range: 1 - 40 $qr = new \Esyede\TinyQRCode\TinyQRCode($data, $options); $qr->display();
Possible option lists:
| Key | Type | Description |
|---|---|---|
'version' |
integer | Set QR Code version |
'imageSize' |
integer | Set output image size |
'errorCorrectionLevel' |
string | Set error correction level |
'dataPath' |
string | Set custom stub data folder |
'imagesPath' |
string | Set custom stub images folder |
License
Released under the MIT License
统计信息
- 总下载量: 157
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-05
