laranail/console
Composer 安装命令:
composer require laranail/console
包简介
A Rich-class console toolkit for Laravel — fluent output formatter, spinners, progress bars, boxes, trees and tables, plus a fluent prompts/forms layer with validators.
关键字:
README 文档
README
A Rich-class console toolkit for Laravel. One package, two namespaces:
Console\Tools— terminal output: a fluent formatter, spinners, flavoured progress bars, boxes, trees, tables, banners, gauges, sparklines, a multi-task progress widget, plus an enhanced Artisan command base.Console\Prompter— terminal input: a fluent wrapper overlaravel/promptswith a form builder and 25+ validators.
Targets PHP ^8.3 (8.3–8.5) on Laravel ^13.
Install
composer require laranail/console
The service provider, the Console and Prompter facades, and the global
prompter() helper are auto-discovered. Publish the config and language files
if you want to customise them:
php artisan vendor:publish --tag=console-config php artisan vendor:publish --tag=console-lang
Quick start
use Simtabi\Laranail\Console\Facades\Console; // Output echo Console::status()->success('Build complete'); echo Console::box(['Name: app', 'Env: prod'])->title('Config')->render(); echo Console::tree('project')->child('src', fn ($t) => $t->child('Console'))->render(); echo Console::gauge(72, 100)->label('Disk')->showValue()->render(); Console::spinner('Compiling…')->run(fn () => compile()); $bar = Console::progress(max: count($items))->format('detailed')->glyphs('blocks'); $bar->start(); foreach ($items as $item) { process($item); $bar->advance(); } $bar->finish(); // Multi-task progress (exits non-zero if any task fails) $tasks = Console::tasks(); $tasks->task('Compile', 100)->advance(100)->succeed(); exit($tasks->finish()); // Input $name = Console::prompter()->text('Your name', required: true)->getResult();
Console::ui() returns the underlying fluent ConsoleUIFormatter;
Console::prompter() returns the shared Prompter. The two sub-domains are
fully decoupled — they only meet in the Console aggregator.
Formatter and status strings carry Symfony Console markup (e.g.
<fg=green>…</>). Write them through a console output —$output->writeln(…)or a command's$this->line(…)— so colour renders on a TTY and is stripped cleanly when piped. Plain widgets (box, tree, table, gauge…)echofine.
Security & portability
- All rendered text is stripped of terminal control characters (no ANSI/
\routput spoofing); terminal hyperlinks are limited to an allow-list of URL schemes. - Validators are total — non-string input returns an error rather than throwing.
- Unicode glyphs and colour degrade gracefully: capabilities are detected from
the terminal and honour
NO_COLOR,FORCE_COLOR,TERMand locale; ASCII fallbacks are used when Unicode is unavailable. - Signal handling is guarded by
ext-pcntl, so commands run on Windows too.
Documentation
| Page | What it covers |
|---|---|
| Installation | Requirements, install, publishing |
| Architecture | Umbrella, sub-domains, the manager |
| Configuration | Every config/console.php key |
| Internationalization | Translating console strings |
| Output formatter | Colours, badges, status, links |
| Output widgets | Spinner, progress, box, tree, table, gauge… |
| Commands | The Artisan command base + services |
| Runners | Conditional console execution |
| Notifications | The console channel |
| Observers & events | Command lifecycle hooks |
| Prompts & forms | The Prompter, forms and validators |
License
MIT © Simtabi LLC. See LICENSE.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-18