laravel/prompts
Laravel Prompts adds beautiful, user-friendly interactive forms to PHP CLI apps. Ideal for Laravel Artisan commands, with browser-like touches such as placeholders and built-in validation. Usable in any command-line PHP project.
select, confirm, spinner) is unchanged, ensuring seamless integration into Laravel’s ecosystem.Task prompt) extend functionality without disrupting existing integrations.symfony/console.symfony/console/symfony/process.Prompt::select() for user choices).->validate(fn ($value) => ...)).symfony/console/process; no Laravel-specific ties).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Terminal Compatibility | Fixed in v0.3.18: Spinner/Task prompts now use static rendering when POSIX extension is unavailable (e.g., Windows). No regression for non-POSIX environments. | Test on Windows Terminal and WSL post-update. Monitor GitHub issues for edge cases. |
| POSIX Dependency | Spinner/Task prompts fallback gracefully without POSIX, but may lack advanced features (e.g., real-time updates). | Document fallback behavior in release notes. Use Prompt::text() for critical paths if POSIX is unavailable. |
| Logger Fix (Windows) | Fixed in v0.3.18: Logger now returns properly on Windows without a socket, resolving hangs in Laravel’s CLI tools. | Verify in Windows Laravel environments post-upgrade. No action required for Unix-like systems. |
| Performance | No changes to core performance. Complex prompts (e.g., tables) may still lag in high-frequency CLI tools. | Benchmark in CI/CD; avoid in automated scripts (e.g., cron jobs). |
| Future-Proofing | Actively maintained (0.3.x). No breaking changes in v0.3.18. | Pin to ^0.3 in composer.json. Monitor changelog for future updates. |
echo "Processing..." with Prompt::task('Processing', fn () => sleep(5)).Style or CSS-like syntax if needed.Ctrl+C) be handled in production?retry()/cancel(); define global fallbacks (e.g., Prompt::catch(\Throwable::class, fn () => exit(1))).Prompt::fake() (if available) or mock symfony/console inputs. Test Windows/Linux/macOS matrices.php artisan prompts:setup).Prompt::table()).symfony/console forms.new \Symfony\Component\Console\Application() + new \Laravel\Prompts\Prompt().Prompt::select() for server choices).Prompt::stream() for live updates).| Current State | Migration Strategy | Example |
|---|---|---|
| Basic Artisan Commands | Replace Argument/Option with Prompt::select()/Prompt::text(). |
php<br>// Before<br>$name = $input->argument('name');<br><br>// After<br>$name = Prompt::text('Enter name');<br> |
| Symfony Console Forms | Swap Form components with Prompt::form(). |
php<br>// Before<br>$form = $this->createForm(...);<br><br>// After<br>$result = Prompt::form([<br> 'name' => Prompt::text('Name'),<br>]);<br> |
| Custom CLI Tools | Wrap readline()/fgets() calls in Prompt::* methods. |
php<br>// Before<br>$choice = readline('Pick: ');<br><br>// After<br>$choice = Prompt::select('Pick', ['a', 'b']);<br> |
| Validation Logic | Replace manual checks with Prompt::validate(). |
php<br>// Before<br>if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { ... }<br><br>// After<br>Prompt::text('Email')->validate('email')->required();<br> |
| Spinners/Tasks | Replace static echoes with Prompt::spinner() or Prompt::task() for dynamic progress feedback. |
php<br>// Before<br>echo "Processing...";<br>// After<br>Prompt::task('Processing', fn () => sleep(5));<br> |
symfony/console (^6.4), symfony/process (^6.4).illuminate/collections dependency in 0.3.x).--non-interactive flag for automated scripts.migrate, make:model) with prompts.php artisan prompts:deploy).Prompt::task('Migrating...', fn () => Artisan::call('migrate'))).How can I help you explore Laravel packages today?