Laravel Prompts

Beautiful and user-friendly forms for your command-line PHP applications, with validation and browser-like features.

Library
Composer
vv0.3.23
721stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
84/100Excellent
Development Activity88
Maintenance88
Community68
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture86
Code Quality88
Innovation84
Learning Curve85

Laravel Prompts is a PHP package for adding beautiful, user-friendly input forms to your command-line applications. It provides a rich set of prompt types, text, password, confirm, select, multi-select, search, suggest, textarea, and more, each with browser-like conveniences such as placeholder text, inline validation, and default values.

Though maintained by the Laravel team and used throughout the framework’s own CLI, Prompts is a standalone library with no Laravel dependency: it only requires PHP and Symfony Console, so it works in any PHP CLI project. It also includes higher-level building blocks like a form builder for multi-step flows, spinners, progress bars, tables, and notes, plus graceful fallbacks for unsupported terminals.

What You Get

  • A full set of prompt types: text, password, confirm, select, multiselect, search, suggest, number, and textarea
  • Inline validation, placeholder text, default values, and required-field handling
  • A form builder for composing multi-step, dependent input flows
  • Extra UI primitives: spinners, progress bars, tables, notes, and tasks
  • Graceful fallbacks so prompts still work on terminals that lack interactivity

Common Use Cases

  • Collecting validated input in artisan or standalone PHP console commands
  • Building interactive installers, scaffolding wizards, or setup flows
  • Replacing raw Symfony Console questions with a friendlier, validated UI

Under The Hood

Architecture

Every prompt is a class extending the abstract Prompt base (src/Prompt.php), which owns the render loop, key handling (Key.php), terminal state (Terminal.php, Stream.php), and validation. Concrete prompts like TextPrompt, SelectPrompt, MultiSearchPrompt, and PasswordPrompt implement their own value handling and renderer, while shared behavior lives under Concerns and Support. Themeable renderers under Themes/ produce the visual output, and helpers.php exposes free functions (text(), select(), confirm(), etc.) as the primary user-facing API. FormBuilder and FormStep coordinate multi-prompt flows where each step receives the accumulated responses.

Tech Stack

Pure PHP 8.1+, requiring only ext-mbstring, composer-runtime-api, and symfony/console (6.2 through 8). PSR-4 autoloads under Laravel\Prompts, with helpers.php auto-loaded via composer files autoloading. It has no Laravel framework dependency, making it usable in any PHP CLI project.

Code Quality

The library is large but cleanly organized: each prompt type is isolated, cross-cutting logic is factored into Concerns/Support/Elements, and rendering is separated from input handling. It ships a Pest Feature test suite and a CI tests workflow, and is battle-tested as the prompt layer inside Laravel and its installer.

API Design

The helper-function API is exceptionally ergonomic: a single call like text(‘What is your name?’) returns validated input, with named arguments for placeholder, default, validation, and hints. Extensive official documentation and graceful terminal fallbacks keep the learning curve low.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search