wp-cli/php-cli-tools
PHP Command Line Tools is a collection of functions and classes for building command-line apps in PHP. It provides formatted output, input prompts, menus, progress indicators, ASCII tables, tree displays, and argument parsing. Requires PHP 5.6 or newer.
echo loops with cli\progress\Bar() for consistent progress bars in Laravel migrations or queue workers.cli\Table (e.g., php artisan db:inspect). As of v0.13.2, table rows can be populated directly from an iterator/generator, enabling streaming of large or lazily-loaded result sets (e.g., cursor-based DB queries, paginated API dumps) into a table without materializing everything in memory first.cli\prompt()) to Laravel Artisan commands for configuration or confirmation steps.cli\Tree to visualize Laravel service container bindings or route hierarchy.cli\notify\Spinner for async task feedback in deployment scripts.cli\out_padded() for aligned logs).cursor(), generators, or paginated APIs straight into cli\Table using the new iterator support, keeping memory footprint flat for large datasets.Console component instead.symfony/console, league/cli-table, spatie/cli)."This package lets us standardize and elevate our CLI tools—think of it as ‘Tailwind CSS for PHP command line output.’
echo statements in scripts with consistent, reusable output (tables, progress bars, prompts).cli\progress\Bar into deployment scripts to visually track long-running tasks (e.g., database migrations).
It’s a low-code, high-impact way to modernize our tooling without hiring extra engineers.""This gives us WP-CLI’s battle-tested CLI utilities—but without the WordPress dependency. Key wins:
for loops with cli\progress\Bar for migrations/queue workers (e.g., php artisan migrate --progress).tinker inspection with cli\Table (auto-detects piped output for scripts). v0.13.2 adds iterator-backed rows, so we can stream from cursor(), generators, or paginated APIs without buffering the whole result set.cli\prompt() to Artisan commands for user confirmation (e.g., php artisan deploy --confirm)."If you’re tired of writing custom echo loops or hacking together progress bars, this package saves hours. Example:
// Before: Manual progress bar (error-prone)
for ($i = 0; $i < 100; $i++) {
echo str_repeat('=', $i) . '>' . str_repeat(' ', 100 - $i) . "\r";
}
// After: One-liner with `cli\progress\Bar`
$bar = new \cli\progress\Bar('Processing...', 100);
while ($bar->tick()) { /* ... */ }
New in v0.13.2: feed a table from any iterator—no array preloading:
$table = new \cli\Table();
$table->setHeaders(['ID', 'Name']);
$table->setRows(User::query()->cursor()); // streams rows
$table->display();
It’s MIT-licensed, actively maintained, and used by WP-CLI—so it’s battle-tested for real-world CLI apps."
How can I help you explore Laravel packages today?