diff --git a/examples/MyAuthenticatorClass.php b/examples/MyAuthenticatorClass.php new file mode 100644 index 000000000..8e4ea12e5 --- /dev/null +++ b/examples/MyAuthenticatorClass.php @@ -0,0 +1,33 @@ + + * @copyright 2017 Smiley + * @license MIT + */ + +namespace chillerlan\QRCodeExamples; + +use chillerlan\QRCode\{QRCode, QROptions, Traits\QRAuthenticator}; + +/** + * using the QRAuthenticator trait + */ +class MyAuthenticatorClass{ + use QRAuthenticator; + + public function getQRCode(){ + // data fetched from wherever + $this->authenticatorSecret = 'SECRETTEST234567'; + $this->qrOptions = new QROptions(['outputType' => QRCode::OUTPUT_MARKUP_SVG]); // set options if needed + $label = 'my label'; + $issuer = 'example.com'; + + return $this->getURIQRCode($label, $issuer); + } + +} diff --git a/examples/authenticator.php b/examples/authenticator.php new file mode 100644 index 000000000..544a52cc4 --- /dev/null +++ b/examples/authenticator.php @@ -0,0 +1,17 @@ + + * @copyright 2017 Smiley + * @license MIT + */ + +namespace chillerlan\QRCodeExamples; + +require_once '../vendor/autoload.php'; + +header('Content-type: image/svg+xml'); + +echo (new MyAuthenticatorClass)->getQRCode(); diff --git a/examples/html.php b/examples/html.php new file mode 100644 index 000000000..6e89d3410 --- /dev/null +++ b/examples/html.php @@ -0,0 +1,106 @@ + + * @copyright 2017 Smiley + * @license MIT + */ + +use chillerlan\QRCode\{QRCode, QROptions}; + +require_once '../vendor/autoload.php'; + +header('Content-Type: text/html; charset=utf-8'); + +?> + + + + + + QRCode test + + + +
+ 5, + 'outputType' => QRCode::OUTPUT_MARKUP_HTML, + 'eccLevel' => QRCode::ECC_L, + 'moduleValues' => [ + // finder + 1536 => '#A71111', // dark (true) + 6 => '#FFBFBF', // light (false) + // alignment + 2560 => '#A70364', + 10 => '#FFC9C9', + // timing + 3072 => '#98005D', + 12 => '#FFB8E9', + // format + 3584 => '#003804', + 14 => '#00FB12', + // version + 4096 => '#650098', + 16 => '#E0B8FF', + // data + 1024 => '#4A6000', + 4 => '#ECF9BE', + // darkmodule + 512 => '#080063', + // separator + 8 => '#AFBFBF', + // quietzone + 18 => '#FFFFFF', + ], + ]); + + echo (new QRCode($options))->render($data); + +?> +
+ + + + + diff --git a/examples/svg.php b/examples/svg.php new file mode 100644 index 000000000..0488141b9 --- /dev/null +++ b/examples/svg.php @@ -0,0 +1,55 @@ + + * @copyright 2017 Smiley + * @license MIT + */ + +use chillerlan\QRCode\{QRCode, QROptions}; + +require_once __DIR__.'/../vendor/autoload.php'; + +$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; + +$options = new QROptions([ + 'version' => 5, + 'outputType' => QRCode::OUTPUT_MARKUP_SVG, + 'eccLevel' => QRCode::ECC_L, + 'scale' => 10, + 'moduleValues' => [ + // finder + 1536 => '#A71111', // dark (true) + 6 => '#FFBFBF', // light (false) + // alignment + 2560 => '#A70364', + 10 => '#FFC9C9', + // timing + 3072 => '#98005D', + 12 => '#FFB8E9', + // format + 3584 => '#003804', + 14 => '#00FB12', + // version + 4096 => '#650098', + 16 => '#E0B8FF', + // data + 1024 => '#4A6000', + 4 => '#ECF9BE', + // darkmodule + 512 => '#080063', + // separator + 8 => '#AFBFBF', + // quietzone + 18 => '#FFFFFF', + ], +]); + +header('Content-type: image/svg+xml'); + +echo (new QRCode($options))->render($data); + + + diff --git a/examples/text.php b/examples/text.php new file mode 100644 index 000000000..19e45324a --- /dev/null +++ b/examples/text.php @@ -0,0 +1,29 @@ + + * @copyright 2017 Smiley + * @license MIT + */ + +use chillerlan\QRCode\{QRCode, QROptions}; + +require_once __DIR__.'/../vendor/autoload.php'; + +$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s'; + +$options = new QROptions([ + 'version' => 5, + 'outputType' => QRCode::OUTPUT_STRING_TEXT, + 'eccLevel' => QRCode::ECC_L, +]); + +//
 to view it in a browser
+echo '
'.(new QRCode($options))->render($data).'
'; + + + + + diff --git a/public/index.html b/public/index.html index 2594a2dee..d7bf6c891 100644 --- a/public/index.html +++ b/public/index.html @@ -48,8 +48,8 @@