QR codes

Generate QR codes

Functions

QrCodesGateway::create

Definition

Name
QrCodesGateway::create
Shorthand
qr_codes()->create()
Syntax
String|false = QrCodesGateway::create( String $content [, Array|false $_options ] );

Description

Generate QR code and output as file or string.

Default setting: output png as binary string, 300x300px, margin 0px, black on white background,

Parameters

$content
Mixed Array is converted to json-encoded string. Everything else is directly converted to string.
$_options
Array|False
Options
size (Integer)
size in px
margin (Integer)
margin size in px
-->
output_file (String)
will save the QR code as the specified filename
format (String)
png (default) or svg

Return values

String|False qr code as binary string or path of saved qr code. False on error.

Examples

Generate QR code with the text "test":

qr_codes->("test");

Generate QR code with the text '{"a":1,"b":2}':

qr_codes->(["a" => 1, "b" => 2]);

Generate QR code with the text "test", size is 500x500px:

qr_codes->("test", ["size" => 500]);

Generate QR code with the text "test", saved as specified path:

qr_codes->("test", ["output_file" => "/srv/sites/parentnode/qr.png"]);

Generate QR code with the text "test", saved as specified path as svg:

qr_codes->("test", ["output_file" => "/srv/sites/parentnode/qr.svg", "format" => "svg"]);

Dependencies

Janitor
  • QrCodesGateway::init_adapter
  • JanitorBaconQrCode::create