Weave 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 is a PHP package for adding beautiful, user-friendly forms to command-line apps, with browser-like features including placeholder text and validation. Perfect for Artisan console commands or any CLI PHP project.

View on GitHub
Deep Wiki
Context7

Add beautiful and user-friendly forms to your command-line applications.

Frequently asked questions about Prompts
How do I integrate Laravel Prompts into an existing Laravel Artisan command?
Install via Composer (`composer require laravel/prompts`), then use the fluent API in your command’s `handle()` method. For example, replace `readline()` with `Prompt::text('Enter name:')` for a simple input field. The package auto-detects Laravel’s Artisan environment, so no extra configuration is needed.
Does Laravel Prompts work with non-Laravel PHP CLI applications?
Yes, it’s framework-agnostic. Install via Composer and use the same API in standalone scripts. It relies on Symfony’s Console component, ensuring compatibility with Symfony CLI tools or custom PHP scripts. Just avoid Laravel-specific features like service container bindings.
What Laravel versions are supported by Prompts?
Prompts supports Laravel 10.x and 11.x officially, with backward compatibility for PHP 8.1+. Check the [release notes](https://github.com/laravel/prompts/releases) for version-specific changes. For Laravel 12+, test early as new Artisan features may require updates.
How can I test interactive prompts in CI/CD pipelines?
Use `Prompt::fake()` to mock user input in unit tests. For example, `Prompt::fake(['input' => 'test'])` simulates a text input. Integration tests can use `Prompt::assertPromptWasShown()` to verify prompts appear. This avoids flaky terminal-based tests in CI.
Are there performance concerns with large datasets in multiselect prompts?
For datasets >1,000 items, consider virtual scrolling or pagination to avoid rendering delays. Prompts doesn’t enforce this by default, but you can pre-filter options or use `Prompt::multiselect()->limit(100)` to cap visible items. Test with `php -d detect_unicode=0` on Windows for edge cases.
Can I customize the appearance (e.g., dark mode, themes) of Prompts?
Basic styling (colors, borders) is configurable via `Prompt::style()` or `Prompt::theme()`. For advanced customization, override the `NoteRenderer` or extend the `Prompt` class. Dark mode support is experimental; check the [docs](https://laravel.com/docs/prompts#customization) for ANSI escape sequences.
How does Prompts handle invalid user input (e.g., retries, validation)?
Prompts validates inputs by default (e.g., regex for emails, required checks). Use `->validate(fn ($input) => $input !== 'admin')` for custom rules. Invalid inputs trigger retries automatically unless you disable them with `->attempts(0)`. For complex logic, delegate to your command’s validation.
What are the alternatives to Laravel Prompts for CLI forms in PHP?
For Laravel, alternatives include `symfony/console` (low-level) or `laravel/framework`’s built-in `readline()`. For richer UX, consider `spatie/laravel-command-scheduler` (for scheduling) or `nunomaduro/laravel-console` (enhanced Artisan). For non-Laravel, `symfony/console` or `php-readline` are lightweight options.
Will Prompts break if I upgrade PHP to 8.4+?
Prompts requires PHP 8.1+ and is backward-compatible since v0.1.x. PHP 8.4+ may introduce breaking changes (e.g., new attributes), but the team monitors deprecations. Check the [changelog](https://github.com/laravel/prompts/blob/main/CHANGELOG.md) for version-specific notes before upgrading.
How do I handle Windows-specific issues (e.g., cursor positioning, UTF-8)?
Run tests with `php -d detect_unicode=0` to debug encoding issues. For cursor problems, ensure your terminal supports ANSI escapes (e.g., Windows Terminal or Git Bash). Prompts includes POSIX fallbacks, but complex layouts may need manual adjustments. Report issues via GitHub with your terminal type.
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.
vento/laravel-airbrake
wfeller/laravel-batch
maco-studios/mage-os-installer
busarm/armie
siberfx/laravel-logger
kfteam1991/dcat-admin
dashed/dashed-laposta
dashed/dashed-ecommerce-montaportal
dashed/dashed-ecommerce-etsy
neohq/string-blade-compiler
log1x/acf-composer
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager