Skip to content

A collection of classes to QR enccode strings and render them as PNG, TIFF and vectorized EPS written in PHP.

License

Notifications You must be signed in to change notification settings

chroma-x/php-qr-code-suite

Repository files navigation

QR Code Suite

Code Climate Latest Stable Version Total Downloads License

A collection of classes to QR enccode strings and render them as PNG, TIFF and vectorized EPS.

Requirements

To use the QR Code Suite qrencode and imagick have to be available.

Installation

{
   	"require": {
        "chroma-x/qr-code-suite": "~2.0"
    }
}

Usage

Autoloading and namesapce

require_once('path/to/vendor/autoload.php');

Encoding data as QR code block data

use QrCodeSuite\QrEncode\QrEncoder;

// Encode the data as QR code block data
$encoder = new QrEncoder();
$qrCodeData = $encoder
	->setLevel(QrEncoder::QR_CODE_LEVEL_LOW)
	->setTempDir('path/to/writable/directory')
	->encodeQrCode('https://github.com/chroma-x/php-qr-code-suite');

Render encoded QR code block data as image

use QrCodeSuite\QrRender;

// Render the encoded QR code block data as RGB PNG
$renderer = new QrRender\QrCodeRendererPng();
$renderer->render($qrCodeData, 'path/to/qr-code.png');

// Render the encoded QR code block data as CMYK TIFF
$renderer = new QrRender\QrCodeRendererTiff();
$renderer->render($qrCodeData, 'path/to/qr-code.tif');

// Render the encoded QR code block data as CMYK vectorized EPS
$renderer = new QrRender\QrCodeRendererEps();
$renderer->render($qrCodeData, 'path/to/qr-code.eps');

License

QR Code Suite is under the MIT license.