Explorar el Código

updated examples

smiley hace 9 años
padre
commit
0b177f0b69
Se han modificado 3 ficheros con 29 adiciones y 15 borrados
  1. 20 5
      examples/example.php
  2. 6 7
      examples/html.php
  3. 3 3
      examples/image.php

+ 20 - 5
examples/example.php

@@ -9,6 +9,8 @@
 
 
 require_once '../vendor/autoload.php';
 require_once '../vendor/autoload.php';
 
 
+use chillerlan\QRCode\Output\QRMarkup;
+use chillerlan\QRCode\Output\QRMarkupOptions;
 use chillerlan\QRCode\QRCode;
 use chillerlan\QRCode\QRCode;
 use chillerlan\QRCode\Output\QRImage;
 use chillerlan\QRCode\Output\QRImage;
 use chillerlan\QRCode\Output\QRString;
 use chillerlan\QRCode\Output\QRString;
@@ -62,13 +64,26 @@ $data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
 <body>
 <body>
 <?php
 <?php
 
 
-echo '<img class="qrcode" alt="qrcode" src="'.(new QRCode($data, new QRImage))->output().'" />';
-echo '<div class="qrcode">'.(new QRCode($data, new QRString))->output().'</div>';
+// image
+echo '<img alt="qrcode" src="'.(new QRCode($data, new QRImage))->output().'" />';
 
 
-$qrStringOptions = new QRStringOptions;
-$qrStringOptions->type = QRCode::OUTPUT_STRING_TEXT;
+// markup - svg
+echo '<div>'.(new QRCode($data, new QRMarkup))->output().'</div>';
 
 
-echo '<pre class="qrcode">'.(new QRCode($data, new QRString($qrStringOptions)))->output().'</pre>';
+// markup - html
+$outputOptions = new QRMarkupOptions;
+$outputOptions->type = QRCode::OUTPUT_MARKUP_HTML;
+
+echo '<div class="qrcode">'.(new QRCode($data, new QRMarkup($outputOptions)))->output().'</div>';
+
+// string - json
+echo '<pre>'.(new QRCode($data, new QRString))->output().'<pre>';
+
+// string - text
+$outputOptions = new QRStringOptions;
+$outputOptions->type = QRCode::OUTPUT_STRING_TEXT;
+
+echo '<pre>'.(new QRCode($data, new QRString($outputOptions)))->output().'</pre>';
 
 
 ?>
 ?>
 </body>
 </body>

+ 6 - 7
examples/html.php

@@ -2,8 +2,8 @@
 
 
 require_once '../vendor/autoload.php';
 require_once '../vendor/autoload.php';
 
 
-use chillerlan\QRCode\Output\QRString;
-use chillerlan\QRCode\Output\QRStringOptions;
+use chillerlan\QRCode\Output\QRMarkup;
+use chillerlan\QRCode\Output\QRMarkupOptions;
 use chillerlan\QRCode\QRCode;
 use chillerlan\QRCode\QRCode;
 use chillerlan\QRCode\QROptions;
 use chillerlan\QRCode\QROptions;
 
 
@@ -42,14 +42,13 @@ echo '<style>
 
 
 </style>';
 </style>';
 
 
-$qrStringOptions = new QRStringOptions;
-$qrStringOptions->type = QRCode::OUTPUT_STRING_HTML;
-$qrStringOptions->eol = '';
+$qrStringOptions = new QRMarkupOptions;
+$qrStringOptions->type = QRCode::OUTPUT_MARKUP_HTML;
 
 
 $qrOptions = new QROptions;
 $qrOptions = new QROptions;
 $qrOptions->typeNumber = QRCode::TYPE_05;
 $qrOptions->typeNumber = QRCode::TYPE_05;
-$qrOptions->errorCorrectLevel = QRCode::ERROR_CORRECT_LEVEL_M;
+$qrOptions->errorCorrectLevel = QRCode::ERROR_CORRECT_LEVEL_L;
 
 
-$qr = new QRCode('skype://callto:echo123', new QRString($qrStringOptions), $qrOptions);
+$qr = new QRCode('skype://callto:echo123', new QRMarkup($qrStringOptions), $qrOptions);
 
 
 echo '<div class="qrcode">'.$qr->output().'</div>';
 echo '<div class="qrcode">'.$qr->output().'</div>';

+ 3 - 3
examples/image.php

@@ -8,8 +8,8 @@ use chillerlan\QRCode\QRCode;
 
 
 $qrImageOptions = new QRImageOptions;
 $qrImageOptions = new QRImageOptions;
 $qrImageOptions->pixelSize = 10;
 $qrImageOptions->pixelSize = 10;
-#$qrImageOptions->cachefile = 'example_image.png';
+$qrImageOptions->cachefile = 'example_image.png';
 
 
-$im = (new QRCode('https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s', new QRImage($qrImageOptions)))->output();
+(new QRCode('https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s', new QRImage($qrImageOptions)))->output();
 
 
-echo '<img src="'.$im.'" />';
+echo '<img src="'.$qrImageOptions->cachefile.'" />';