custom_output.php 879 B

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