endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.45k stars 726 forks source link

Writer and Result classes for printing a QR-Code on a console #378

Closed Trismegiste closed 2 years ago

Trismegiste commented 2 years ago

Hello,

I've created a new Writer for printing a QR Code on Command Line Interface. I find it very useful to get data or link from a server to your smartphone.

You can expect something like this for example :

Capture d’écran de 2022-06-30 10-53-16

(since it uses UTF-8, it should probably fail on Windows)

Usage

require_once __DIR__ . '/vendor/autoload.php';

use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Writer\ConsoleWriter;

$result = Builder::create()
        ->writer(new ConsoleWriter())
        ->data($argv[1])
        ->build();

echo $result->getString();

Hope this helps :cherry_blossom:

Trismegiste commented 2 years ago

Sorry, took me a while to check with PHPStan

endroid commented 2 years ago

@Trismegiste sorry for the late response. I was enjoying my vacation ;) Really nice feature, great addition! Regarding the dark mode: I would really prefer to use the current QR code foreground and background color for this. If you could make it so that those colors are used we can create a dark mode using the current interface (and if really wanted, create a separate MR for creating a global dark mode setting).

Trismegiste commented 2 years ago

Done :coffee: image

endroid commented 2 years ago

@Trismegiste thank you. I have to fix some new QA issues I see (not caused by your changes) before I tag the new version but your feature is merged :)

endroid commented 2 years ago

Tag 4.5.0