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

Beautiful and user-friendly forms for your command-line PHP applications.

Frequently asked questions about Prompts
How do I use Laravel Prompts in a Laravel Artisan command?
Install via Composer (`composer require laravel/prompts`), then use methods like `Prompt::text()`, `Prompt::select()`, or `Prompt::confirm()` in your command’s `handle()` method. For example, `Prompt::text('Enter name', ['required' => true])` collects input with validation. Works seamlessly with Laravel’s Artisan framework.
Does Laravel Prompts support validation like Laravel’s Form Requests?
Yes. Use `Prompt::text()->validateWith()` to pass Laravel validation rules (e.g., `['required', 'email']`) or custom callables. It integrates with Laravel’s validation system, so you can reuse existing rules or write new ones for CLI inputs.
Can I use Laravel Prompts in non-Laravel PHP CLI tools?
Absolutely. Laravel Prompts relies on Symfony Console, so it works in any PHP CLI project. Install it via Composer, then use the same methods (e.g., `Prompt::select()`) in standalone scripts or libraries. No Laravel dependencies are required beyond Symfony Console.
What Laravel versions are compatible with Laravel Prompts?
Laravel Prompts supports Laravel 10.x and 11.x. It also works with PHP 8.1+ standalone (non-Laravel) projects. Check the [latest release notes](https://github.com/laravel/prompts/releases) for version-specific details or breaking changes.
How do I test interactive prompts in CI/CD pipelines?
Use `Prompt::fake()` to mock prompts in PHPUnit or Pest tests. For example, `Prompt::fake(['name' => 'test']);` simulates user input. This lets you test validation and logic without manual CLI interaction, making it ideal for automated workflows.
Are there alternatives to Laravel Prompts for CLI forms?
Yes. For Laravel, consider Symfony Console’s built-in methods (e.g., `$helper->choice()`), but they lack browser-like UX features. For PHP, alternatives include `symfony/console` (basic), `react/prompts` (more advanced), or `laravel/framework`’s native helpers. Laravel Prompts stands out for its validation, placeholders, and Artisan integration.
How do I handle multiline text input or password fields?
Use `Prompt::text()->password()` for masked input (e.g., passwords) or `Prompt::text()->multiline()` for paragraphs. Both support validation and placeholders. For example: `Prompt::text('Enter notes')->multiline()->validateWith(['required'])`.
Can I customize the appearance of prompts (colors, styles)?
Yes. Laravel Prompts uses Symfony Console’s style system, so you can override colors, padding, or formatting via `$prompt->style()` or by extending the `Prompt` class. For example, `Prompt::text()->style('warning')` changes the text color. Check the [documentation](https://laravel.com/docs/prompts) for styling options.
Does Laravel Prompts work in Windows Terminal or WSL?
Yes, Laravel Prompts is cross-platform and tested on Windows Terminal, WSL, Linux, and macOS. It handles multibyte strings and edge cases (e.g., ANSI escape sequences) gracefully. For older terminals, fallbacks ensure basic functionality.
How do I disable prompts in non-interactive environments (e.g., CI)?
Use the `--non-interactive` flag in your command’s definition (e.g., `php artisan my:command --non-interactive`). This skips prompts and uses defaults or fails gracefully. Alternatively, check `Prompt::isInteractive()` in code to conditionally bypass prompts.
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