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.
cli\Table, cli\progress\Bar), its core design assumes WP-CLI integration (e.g., Behat testing, WordPress-specific commands). For Laravel, it offers partial fit for:
WP_CLI class, not Laravel’s Illuminate\Console.wp-cli/wp-cli, Behat).str_contains deprecations).cli\Table can now render rows from an iterator (#204). This is a backwards-compatible enhancement that improves fit for one of the strongest Laravel use cases — streaming large result sets into tables without materializing the full dataset in memory.WP_CLI to Laravel’s Artisan.cli\Table/cli\progress\Bar directly.wp-cli/wp-cli, Behat), adding ~50MB to vendor/ and potential conflicts.cli\Table is new in v0.13.2; validate edge cases (single-pass iterators, generators that must be rewound, buffered column-width calculation) before relying on it in production commands.laravel/testbench/pestphp/pest for CLI testing?wp-cli/php-cli-core) to avoid WP-CLI dependencies?cli\Table/cli\progress\Bar add significant overhead to Artisan commands? Does iterator input (v0.13.2) materially reduce memory for our large-dataset reporting commands?| Laravel Component | Compatibility | Workaround |
|---|---|---|
| Artisan CLI | ❌ Low | Create a wrapper class (e.g., WPCLIAdapter) to bridge WP_CLI ↔ Artisan. |
| Symfony Console | ✅ Medium | Reuse cli\Table/cli\progress\Bar directly; avoid WP-CLI-specific classes. |
| PHPUnit/Pest | ⚠️ Partial | Use Behat only for WP-specific tests; replace with Pest for Laravel logic. |
| Laravel Mix/Webpack | ❌ None | Not applicable. |
| Homestead/Valet | ❌ None | Not applicable. |
Phase 1: Proof of Concept (2 weeks)
cli\Table, cli\progress\Bar) in a non-WP Laravel project.composer require wp-cli/php-cli-tools --dev.cli\Table for output (e.g., php artisan debug:table).LazyCollection/generator source.Symfony\Component\Console\Helper\Table).LazyCollection and does not double-iterate the source.Phase 2: Dependency Isolation (3 weeks)
laravel-cli-tools).wp-cli/php-cli-tools and remove WP-CLI-specific code (e.g., WP_CLI class, Behat hooks).cli\Table with a Laravel-compatible renderer (e.g., using Symfony\Component\Console\Style\SymfonyStyle), preserving iterator input support if adopted.Phase 3: Gradual Adoption (Ongoing)
php artisan commands using cli\progress\Bar for long-running tasks.composer test (from WP-CLI) as a pre-commit hook for code quality.WP_CLI::run()).cli\Table/cli\progress\Bar.cli\Table, cli\progress\Bar) → Highest reuse value; iterator-backed tables now raise this value further for reporting commands.cli\process) → Medium (Laravel has Symfony\Process).wp scaffold).replace in composer.json to point to a forked version.CONTRIBUTING.md for Laravel-specific adaptations.cli\Table may fail in non-interactive environments (fixed in #146).composer test to catch issues early.STDERR for debugging (e.g., cli\err()).cli\Table uses mbstring for Unicode support; may slow down large datasets.
Symfony\Component\Console\Helper\Table where iterator support is not needed.How can I help you explore Laravel packages today?