custom_output.php 921 B

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