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.

Maintainers

Package info

github.com/laranail/console

Homepage

Documentation

pkg:composer/laranail/console

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 3

v0.1.0 2026-06-18 12:10 UTC

README

Latest version on Packagist Tests Static analysis License: MIT

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 over laravel/prompts with 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…) echo fine.

Security & portability

  • All rendered text is stripped of terminal control characters (no ANSI/\r output 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, TERM and 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.