Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ANSI QR Code

A PHP library for generating QR codes in the terminal using ANSI escape codes.

PHP Version License

Terminal QR Demo

Command Line Tool

CLI Demo

Features

  • ANSI Renderer: Uses half-block characters (▀, ▄, █) and ANSI colors to render high-resolution QR codes in the terminal.
  • ASCII Renderer: Fallback renderer using full block characters (██) and spaces for broader compatibility.
  • Auto-detection: Automatically selects the best renderer based on terminal capabilities (TTY, NO_COLOR, TERM).
  • Zero Dependencies: Only requires bacon/bacon-qr-code for matrix generation.
  • Static Analysis: Strict type checking with PHPStan (max level).
  • Coding Standard: Adheres to brzuchal/coding-standard.

Installation

composer require brzuchal/ansi-qr-code

Installation

One-liner (Recommended)

Installs the qr command to ~/.local/bin.

curl -s https://raw.githubusercontent.com/brzuchal/ansi-qr-code/1.1/install.sh | bash

Composer

composer global require brzuchal/ansi-qr-code

Usage

Command Line

After installing the package globally or in a project, you can use the qr command:

# If installed globally
qr "https://github.com/brzuchal/ansi-qr-code"

# If installed in a project
vendor/bin/qr "Your text here"

PHP Code

use Brzuchal\TerminalQr\TerminalQrCode;

$qr = new TerminalQrCode();

// Write directly to STDOUT
$qr->write('https://github.com/brzuchal/ansi-qr-code');

// Or get the rendered string
$output = $qr->render('https://github.com/brzuchal/ansi-qr-code');
echo $output;

Customizing Renderer

You can choose between AnsiRenderer (default) and AsciiRenderer:

use Brzuchal\TerminalQr\TerminalQrCode;
use Brzuchal\TerminalQr\Renderer\AsciiRenderer;

// Use ASCII renderer (full blocks)
$qr = new TerminalQrCode(new AsciiRenderer());
$qr->write('https://example.com');

Requirements

  • PHP ^8.3
  • bacon/bacon-qr-code ^2.0

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages