custom_output.php 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  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;
  12. use chillerlan\QRCode\QROptions;
  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' => QRCode::ECC_L,
  19. ]);
  20. $qrOutputInterface = new MyCustomOutput($options, (new QRCode($options))->getMatrix($data));
  21. var_dump($qrOutputInterface->dump());
  22. // or just
  23. $options = new QROptions([
  24. 'version' => 5,
  25. 'eccLevel' => QRCode::ECC_L,
  26. 'outputType' => QRCode::OUTPUT_CUSTOM,
  27. 'outputInterface' => MyCustomOutput::class,
  28. ]);
  29. var_dump((new QRCode($options))->render($data));