bramus/ansi-php
bramus/ansi-php is a lightweight PHP library for working with ANSI escape codes in the terminal. Easily colorize and style CLI output, move the cursor, clear sections of the screen, and build richer command-line interfaces with minimal setup.
artisan commands, custom scripts).symfony/console, laravel-zero/framework).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| ANSI Incompatibility | Medium | Feature detection + fallback (e.g., if (str_contains(PHP_OS, 'WIN'))). |
| Windows Support | Low | Document requirements; use symfony/console for cross-platform CLI. |
| Laravel-Specific Issues | None | Pure PHP; no Laravel core conflicts. |
| Maintenance | Low | MIT-licensed; active community (95 stars). |
symfony/console in Laravel 10+)?bramus/ansi-php needed for simplicity or specific features (e.g., custom sequences)?laravel-zero/framework)?php artisan my:cli-tool).tinker or horizon:work output readability.monolog or custom log files with colors.symfony/console-based tools.composer require bramus/ansi-php.use Bramus\Ansi\Cli;
use Bramus\Ansi\Style;
Cli::write(Style::success('Success!')->text('Operation completed.'));
if (!Cli::supportsAnsi()) {
Cli::write('Colors disabled (ANSI not supported).');
}
\G for green) with bramus/ansi-php.symfony/console (built-in ANSI support).\033[32m escapes in existing CLI code.php artisan migrate feedback).laravel-zero routes).Cli::write(), Style::*).| Scenario | Impact | Mitigation |
|---|---|---|
| ANSI-Unsupported Terminal | Broken formatting | Fallback to plain text. |
| Windows Without ANSI | Colors disabled | Document requirements; use symfony/console. |
| PHP CLI Bugs | ANSI escapes ignored | Test on multiple PHP versions. |
| Package Abandonment | Long-term risk | Fork or migrate to symfony/console. |
How can I help you explore Laravel packages today?