laravel/prompts
Laravel Prompts adds beautiful, user-friendly interactive forms to PHP CLIs, with browser-like UX such as placeholders and validation. Ideal for Laravel Artisan commands, but works in any command-line PHP project.
select, confirm, text, multiselect, number, password, spinner, progress, grid, stream, title, notify) enable granular integration—ideal for feature-rich CLI tools or admin interfaces.spinner, progress, stream) for long-running tasks, critical for CLI tool responsiveness.symfony/console core).Prompt::fake()) simplify unit/integration testing of CLI logic.| Risk Area | Mitigation | Severity |
|---|---|---|
| Terminal Compatibility | POSIX fallback for non-Unix systems (e.g., Windows) via static rendering. | Low |
| Multibyte Character Support | Explicit handling for UTF-8/emoji in textareas and grids (e.g., NoteRenderer fixes). |
Medium |
| Performance Overhead | Minimal for simple prompts; complex prompts (e.g., grid, multiselect) may impact large datasets. |
Low |
| Dependency Bloat | Lightweight (~1MB installed). No Laravel-specific dependencies post-v0.3.0 (removed illuminate/collections). |
None |
| Breaking Changes | Backward-compatible since v0.1.x. Changelog highlights deprecations (e.g., PHP 8.4+ required). | Low |
| Non-Interactive Mode | Graceful degradation (e.g., --non-interactive flag) for CI/CD or headless environments. |
Low |
Use Case Scope:
fgets, symfony/console) or augment existing flows?tinker or make:model commands adopt Prompts for richer UX?Customization Needs:
Performance Constraints:
multiselect with 10K+ items), will virtual scrolling or pagination be needed?Testing Strategy:
Prompt::fake() or mock terminal input.)Error Handling:
Cross-Platform Quirks:
PHP_EOL, cursor positioning) a concern? (Test with php -d detect_unicode=0 if needed.)Future-Proofing:
make:, migrate:, queue:work).| Phase | Action | Tools/Dependencies |
|---|---|---|
| Assessment | Audit existing CLI commands for input collection patterns (e.g., readline, symfony/console). |
grep -r "fgets|readline|symfony/console" |
| Pilot | Replace 1–2 commands with Prompts (e.g., make:model → Prompt::select()). |
laravel/prompts:^0.3 |
| Refactor | Extract input logic into Prompt service classes for reuse. | Dependency Injection (Laravel Container) |
| Testing | Add Prompt::fake() tests for interactive flows. |
PestPHP/PHPUnit |
| Rollout | Gradually replace legacy input methods in remaining commands. | CI/CD validation |
conemu or WSL).symfony/console (included in Laravel).nick-fields/retry (for retry logic in prompts).text, confirm) before complex prompts (e.g., grid, multiselect).Prompt::info(), Prompt::error(), and Prompt::warning() for non-interactive output.readline() with Prompt::text().Prompt::text()->required()->regex()).Prompt::form()).Prompt::multiselect()->pageSize(10).select choices) if static.laravel/prompts) for all CLI tools.illuminate/collections).date prompt) requires maintaining forks or PRs.Prompt::debug() to log terminal interactions.Prompt::isInteractive() for non-interactive mode issues.PHP_EOL and ANSI escape sequences are handled (test with php -d detect_unicode=0).Prompt::text()->validate(fn($input) => var_dump($input)).Prompt::spinner()->start() for long-running operations.--force or --non-interactive flags.Prompt::text()->whenNotInteractive(fn() => 'default').Prompt::confirm('Proceed?')).How can I help you explore Laravel packages today?