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 CLIs, with browser-like UX such as placeholders and validation. Ideal for Laravel Artisan commands, but works in any command-line PHP project.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • CLI-First Design: Laravel Prompts is purpose-built for Artisan commands and CLI applications, aligning perfectly with Laravel’s ecosystem. It abstracts terminal interaction complexity (e.g., ANSI escapes, keybindings) behind a fluent API, reducing boilerplate for input collection.
  • Component-Based: Modular prompts (e.g., select, confirm, text, multiselect, number, password, spinner, progress, grid, stream, title, notify) enable granular integration—ideal for feature-rich CLI tools or admin interfaces.
  • Validation & Transformation: Built-in validation (e.g., regex, callbacks) and data transformation (e.g., casting) streamline input sanitization, reducing custom validation logic in commands.
  • Non-Blocking & Async: Supports asynchronous operations (e.g., spinner, progress, stream) for long-running tasks, critical for CLI tool responsiveness.
  • Form Workflows: Conditional steps, reversible forms, and multi-step flows enable complex user journeys (e.g., migrations, deployments, or interactive setups) without manual state management.

Integration Feasibility

  • Laravel Native: Zero-config integration with Laravel’s Artisan (autoloads via Composer). Works seamlessly with Laravel’s service container, events, and logging.
  • Standalone PHP: Compatible with non-Laravel PHP CLI apps (e.g., Symfony, custom scripts) via Composer. Minimal dependencies (symfony/console core).
  • Symfony Console Compatibility: Leverages Symfony’s terminal handling, ensuring cross-framework consistency.
  • Testing Support: Mockable prompts (e.g., Prompt::fake()) simplify unit/integration testing of CLI logic.

Technical Risk

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

Key Questions

  1. Use Case Scope:

    • Will Prompts replace all CLI input logic (e.g., fgets, symfony/console) or augment existing flows?
    • Example: Should tinker or make:model commands adopt Prompts for richer UX?
  2. Customization Needs:

    • Are themes, keybindings, or ANSI styling required beyond defaults?
    • Example: Dark mode support for terminal apps.
  3. Performance Constraints:

    • For prompts with large datasets (e.g., multiselect with 10K+ items), will virtual scrolling or pagination be needed?
  4. Testing Strategy:

    • How will interactive prompts be tested in CI? (Use Prompt::fake() or mock terminal input.)
  5. Error Handling:

    • Should prompts retry on failure (e.g., invalid input) or delegate to command logic?
  6. Cross-Platform Quirks:

    • Are Windows-specific issues (e.g., PHP_EOL, cursor positioning) a concern? (Test with php -d detect_unicode=0 if needed.)
  7. Future-Proofing:

    • Will the team adopt Laravel 13+ features (e.g., new Artisan hooks) that could integrate with Prompts?

Integration Approach

Stack Fit

  • Primary Use Case: Laravel Artisan Commands (e.g., make:, migrate:, queue:work).
  • Secondary Use Cases:
    • Custom CLI Tools: Standalone PHP scripts (e.g., deployment scripts, data migration tools).
    • Laravel Telescope/Horizon: Enhance admin interfaces with interactive prompts.
    • Laravel Forge/Envoyer: Interactive deployment workflows.
  • Anti-Patterns:
    • Avoid for high-frequency CLI operations (e.g., API polling) where Prompts add latency.
    • Not suitable for web-based forms (use Laravel Blade/Inertia instead).

Migration Path

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:modelPrompt::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

Compatibility

  • Laravel Versions: Supports Laravel 10–13 (tested via CI). Drop-in for older versions with minor tweaks.
  • PHP Versions: PHP 8.1+ (required for v0.3.x). PHP 8.4+ recommended for full feature support.
  • Terminal Environments:
    • Unix/Linux/macOS: Full ANSI support (colors, keybindings).
    • Windows: POSIX fallback for basic functionality (test with conemu or WSL).
  • Dependencies:
    • Required: symfony/console (included in Laravel).
    • Optional: nick-fields/retry (for retry logic in prompts).

Sequencing

  1. Start Simple: Replace basic input (e.g., text, confirm) before complex prompts (e.g., grid, multiselect).
  2. Leverage Helpers: Use Prompt::info(), Prompt::error(), and Prompt::warning() for non-interactive output.
  3. Progressive Enhancement:
    • Phase 1: Replace readline() with Prompt::text().
    • Phase 2: Add validation (e.g., Prompt::text()->required()->regex()).
    • Phase 3: Implement multi-step forms (e.g., Prompt::form()).
  4. Performance Optimization:
    • For large datasets, use Prompt::multiselect()->pageSize(10).
    • Cache prompt options (e.g., select choices) if static.

Operational Impact

Maintenance

  • Pros:
    • Centralized Updates: Single Composer dependency (laravel/prompts) for all CLI tools.
    • Active Development: Frequent releases (monthly) with bug fixes (e.g., Windows support, PHP 8.4).
    • Community Support: 700+ stars, Laravel-backed, and GitHub discussions.
  • Cons:
    • Breaking Changes: Minor version bumps may require updates (e.g., v0.3.x removed illuminate/collections).
    • Custom Prompts: Extending core prompts (e.g., adding a date prompt) requires maintaining forks or PRs.

Support

  • Debugging:
    • Use Prompt::debug() to log terminal interactions.
    • Check Prompt::isInteractive() for non-interactive mode issues.
  • Common Issues:
    • Windows: Ensure PHP_EOL and ANSI escape sequences are handled (test with php -d detect_unicode=0).
    • Validation: Debug with Prompt::text()->validate(fn($input) => var_dump($input)).
    • Performance: Profile with Prompt::spinner()->start() for long-running operations.
  • Fallbacks:
    • Non-interactive mode: Provide --force or --non-interactive flags.
    • Legacy systems: Use Prompt::text()->whenNotInteractive(fn() => 'default').

Scaling

  • Command Complexity:
    • Simple: Single prompt (e.g., Prompt::confirm('Proceed?')).
    • **Moderate
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony