brzuchal/ansi-qr-code
最新稳定版本:1.1.4
Composer 安装命令:
composer require brzuchal/ansi-qr-code
包简介
PHP library for creating QR codes in ANSI format for terminal
README 文档
README
A PHP library for generating QR codes in the terminal using ANSI escape codes.
Command Line Tool
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-codefor 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
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-19

