custom_output.php 959 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. use chillerlan\QRCode\Common\EccLevel;
  13. require_once __DIR__.'/../vendor/autoload.php';
  14. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  15. // invoke the QROutputInterface manually
  16. $options = new QROptions([
  17. 'version' => 5,
  18. 'eccLevel' => EccLevel::L,
  19. ]);
  20. $qrcode = new QRCode($options);
  21. $qrcode->addByteSegment($data);
  22. $qrOutputInterface = new MyCustomOutput($options, $qrcode->getMatrix());
  23. var_dump($qrOutputInterface->dump());
  24. // or just
  25. $options = new QROptions([
  26. 'version' => 5,
  27. 'eccLevel' => EccLevel::L,
  28. 'outputType' => QRCode::OUTPUT_CUSTOM,
  29. 'outputInterface' => MyCustomOutput::class,
  30. ]);
  31. var_dump((new QRCode($options))->render($data));