custom_output.php 924 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. *
  4. * @filesource custom_output.php
  5. * @created 24.12.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCodeExamples;
  11. use chillerlan\QRCode\{QRCode, QROptions};
  12. require_once __DIR__.'/../vendor/autoload.php';
  13. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  14. // invoke the QROutputInterface manually
  15. $options = new QROptions([
  16. 'version' => 5,
  17. 'eccLevel' => QRCode::ECC_L,
  18. ]);
  19. $qrcode = new QRCode($options);
  20. $qrcode->addByteSegment($data);
  21. $qrOutputInterface = new MyCustomOutput($options, $qrcode->getMatrix());
  22. var_dump($qrOutputInterface->dump());
  23. // or just
  24. $options = new QROptions([
  25. 'version' => 5,
  26. 'eccLevel' => QRCode::ECC_L,
  27. 'outputType' => QRCode::OUTPUT_CUSTOM,
  28. 'outputInterface' => MyCustomOutput::class,
  29. ]);
  30. var_dump((new QRCode($options))->render($data));