Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Prompts Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • CLI-First Design: Laravel Prompts remains optimized for Artisan commands and CLI workflows, with no architectural shifts. The core component-based design (e.g., select, confirm, spinner) is unchanged, ensuring seamless integration into Laravel’s ecosystem.
  • Component-Based: Modularity persists, allowing granular adoption. New features (e.g., Task prompt) extend functionality without disrupting existing integrations.
  • Laravel Synergy: Continues to leverage Laravel’s service container and validation, with no breaking changes to core dependencies. Non-Laravel PHP projects remain compatible via symfony/console.

Integration Feasibility

  • Laravel Compatibility:
    • Zero-config for Laravel 11–13. Non-Laravel projects still require symfony/console/symfony/process.
    • Artisan Command Integration: Prompts can replace static arguments/options with dynamic inputs (e.g., Prompt::select() for user choices).
    • Validation: Native PHP rules or custom callbacks remain supported (e.g., ->validate(fn ($value) => ...)).
  • Non-Laravel PHP:
    • Standalone usage unchanged. No new dependencies introduced in v0.3.18.
    • Dependency Conflict Risk: Minimal (only symfony/console/process; no Laravel-specific ties).

Technical Risk

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.

Key Questions

  1. Use Case Scope:
    • Are spinners/tasks critical for your CLI tools (e.g., long-running migrations)? If yes, test POSIX fallback behavior on Windows.
    • Example: Replace echo "Processing..." with Prompt::task('Processing', fn () => sleep(5)).
  2. User Experience:
    • Does your team use Windows Terminal or WSL? The POSIX fix ensures smoother spinner/task rendering.
    • Customize styles/themes via Symfony Style or CSS-like syntax if needed.
  3. Error Handling:
    • How should interrupted prompts (e.g., Ctrl+C) be handled in production?
    • Prompts includes retry()/cancel(); define global fallbacks (e.g., Prompt::catch(\Throwable::class, fn () => exit(1))).
  4. Testing:
    • How will interactive prompts be tested in CI/CD?
    • Use Prompt::fake() (if available) or mock symfony/console inputs. Test Windows/Linux/macOS matrices.
  5. Scaling:
    • Will prompts be used in high-frequency CLI tools (e.g., real-time monitoring)?
    • Avoid in automated scripts; reserve for interactive admin tools.

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Artisan Commands: Ideal for admin tools, migrations, or scaffolding (e.g., php artisan prompts:setup).
    • Laravel Sail: Works in containerized environments (test terminal compatibility post-v0.3.18).
    • Livewire/Telescope: Extend prompts to debugging tools (e.g., interactive data queries with Prompt::table()).
  • Non-Laravel PHP:
    • Symfony Console Apps: Drop-in replacement for symfony/console forms.
    • Standalone Scripts: Use new \Symfony\Component\Console\Application() + new \Laravel\Prompts\Prompt().
  • Third-Party Tools:
    • Laravel Forge/Envoyer: Enhance deployment prompts (e.g., Prompt::select() for server choices).
    • Octane CLI: Integrate with real-time CLI tools (e.g., Prompt::stream() for live updates).

Migration Path

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>

Compatibility

  • PHP Versions: Unchanged (8.1–8.4).
  • Laravel Versions: Officially supports 11–13; test on 10.x if required.
  • Dependencies:
    • Required: symfony/console (^6.4), symfony/process (^6.4).
    • Optional: None (removed illuminate/collections dependency in 0.3.x).
  • Terminal Requirements:
    • Fixed in v0.3.18: Spinner/Task prompts now fallback to static rendering without POSIX (e.g., Windows).
    • Fallback: Provide --non-interactive flag for automated scripts.

Sequencing

  1. Pilot Phase:
    • Integrate into one low-risk Artisan command (e.g., a custom admin tool).
    • Test on Windows/macOS/Linux (focus on Windows Terminal for spinner/task fixes).
  2. Core Integration:
    • Replace critical input points (e.g., migrate, make:model) with prompts.
    • Add validation and error handling layers.
  3. Advanced Features:
    • Implement forms for multi-step workflows (e.g., php artisan prompts:deploy).
    • Use spinners/tasks for long-running operations (e.g., Prompt::task('Migrating...', fn () => Artisan::call('migrate'))).
  4. Optimization:
    • Profile performance in CI/CD pipelines.
    • Cache static prompt data (e.g., select options) if dynamic loading is slow.

Operational Impact

Maintenance

  • Dependency Updates:
    • GitHub Actions: Now pinned to commit SHAs (reduces CI
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai