custom_output.php 841 B

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