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.
Requires
- php: ^8.4.1
- ext-mbstring: *
- illuminate/console: ^13.0
- illuminate/contracts: ^13.0
- illuminate/support: ^13.0
- laravel/prompts: ^0.3.18|^1.0
- symfony/console: ^8.0
Requires (Dev)
- infection/infection: ^0.33
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- mockery/mockery: ^1.6
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
- phpbench/phpbench: ^1.4
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0
- rector/rector: ^2.0
- roave/security-advisories: dev-latest
- symfony/tui: ^8.2@dev
Suggests
- symfony/tui: (experimental, PHP >= 8.4.1) Enables the full-screen TUI integration — Console::tui() + Console\Tui\RenderableWidget.
Replaces
- laranail/console-tools: *
- laranail/prompter: *
This package is auto-updated.
Last update: 2026-06-23 11:43:43 UTC
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, charts (bar/column/line/scatter/heatmap/histogram/stacked), a typography + Markdown layer, a multi-task progress widget, plus an enhanced Artisan command base.Console\Prompter— terminal input: a fluent wrapper overlaravel/promptswith a form builder and 26 validators.
Targets PHP ^8.4.1 (8.4.1–8.5) on Laravel ^13 (Symfony 8).
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; // Inside an Artisan command you have $this->output; elsewhere use any // Symfony OutputInterface (e.g. new ConsoleOutput()). // Output — markup-bearing helpers go through the output: $output->writeln(Console::status()->success('Build complete')); // Plain renderers return finished strings and echo fine: 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($output, 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($output); $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 a fresh Prompter per call. The two sub-domains
are fully decoupled — they only meet in the Console aggregator. See the
runnable examples for end-to-end demos.
Writing through an output
The package has three output styles — know which you're holding:
| Style | APIs | How to print |
|---|---|---|
Symfony markup (e.g. <fg=green>…</>) |
Console::status(), ConsoleUIFormatter::success()/format()/badge() |
$output->writeln(...) / $this->line(...) — renders colour on a TTY, stripped when piped. Echoing prints literal tags. |
| Finished strings | box, tree, table, panel, columns, keyValue, rule, gauge, sparkline, barChart, columnChart, lineChart, scatterPlot, heatmap, histogram, stackedBar, banner, steps, summary, header, and Color/colorize() (raw ANSI, echo-safe) |
echo or writeln both fine. |
| Self-writing | spinner, progress, tasks |
They write to the output you pass them. |
| Interactive | prompter, menu, keypress, tui |
They read input / run a loop and return values — not render strings. |
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 |
| Design system | Theme, typography, documents, responsiveness — the big picture |
| Architecture | Umbrella, sub-domains, the manager |
| Configuration | Every config/console.php key |
| Internationalization | Translating console strings |
| Theming | Semantic palette + per-element styles (design tokens) |
| Colours & styles | Color parsing/downgrade/gradient + the fluent Style |
| Typography | Headings, paragraphs, lists, links, quotes, code, Text |
| Markdown | Render a Markdown subset to the terminal |
| Charts | Bar, column, line, scatter, heatmap, histogram, stacked |
| Emoji | :shortcode: rendering + ASCII fallback |
| Symbols | Capability-aware glyphs |
| Responsive output | How widgets adapt to the terminal width |
| Interactive & live | Live engine, animated bar, badges/pills, buttons |
| Output formatter | Colour/badge/link string primitives |
| Output widgets | Spinner, progress (+ETA), box, tree, table, gauge, summary, bar chart… |
| Banner designer | FIGlet big-text, alignment, colour/gradient, borders |
| Panel layout | Multi-column / nestable layout (Panel + PanelBlock) |
| Interactive menu | Key-driven menu with a prompts fallback |
| Full-screen TUI | symfony/tui integration — mount our widgets in a TUI app |
| Support utilities | Capabilities, Color, DisplayWidth, Emoji, Figlet, Keypress, Terminal, ANSI primitives |
| Commands | The Artisan command base + services (or the InteractsWithConsoleServices trait) |
| Runners | Conditional console execution |
| Notifications | The console channel |
| Observers & events | Command lifecycle hooks |
| Prompts & forms | The Prompter, forms and validators |
| Release process | How a version is cut and published |
| Upgrading | Breaking-change migration notes (1.x → 2.0) |
| Testing | Force capabilities + script prompts in tests |
Online docs: https://opensource.simtabi.com/console/docs/ · Changelog: CHANGELOG.md.
Requires PHP
^8.4.1(Laravel^13, Symfony 8). The core installs from stable releases — nominimum-stabilitychange needed. The full-screensymfony/tuiintegration is optional:composer require symfony/tui(experimental, needs"minimum-stability": "dev") only if you want it.
Stability
laranail/console is 2.x stable and follows SemVer. The public
API — the Console/Prompter facades and the documented Tools\*/Prompter\*
classes — is stable; breaking changes only land in a major. Classes marked
@internal, and the experimental full-screen TUI (Console::tui() /
symfony/tui), are not covered by the BC guarantee. See
Versioning & stability.
Local development
composer install composer test # vendor/bin/pest --no-coverage (composer test-coverage for coverage) composer lint # pint + phpstan + rector --dry-run composer audit # composer audit (security advisories)
Sister packages
laranail/database-tools— standalone Laravel database utilities (traits, casts, schema macros, backup).laranail/package-tools— runtime base library for building Laravel packages.laranail/package-scaffolder— generator that scaffolds new packages.laranail/laranail— Simtabi's Laravel utility toolbox.
Roadmap & community
- ROADMAP.md — direction at a glance (community-driven, no dates).
- Discussions — ideas, questions, proposals.
- Issues — bug reports.
Contributing & security
- CONTRIBUTING.md — development guidelines and PR expectations.
- SECURITY.md — how to report a vulnerability (opensource@simtabi.com).
- CODE_OF_CONDUCT.md — community expectations.
License
MIT © Simtabi LLC. See LICENSE.