esyede / tiny-qrcode
A tiny QRCode generator (single file, no dependencies)
v1.0.0
2022-12-08 10:41 UTC
Requires
- php: >=5.4.0
- ext-gd: *
This package is auto-updated.
Last update: 2025-02-08 15:41:50 UTC
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:
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:
License
Released under the MIT License