When working with Laravel applications, Artisan Commands with Laravel Prompts make development smoother and more interactive. Artisan commands automate tasks, manage data operations, and simplify complex processes. Yet, traditional commands often rely on plain text input, which can feel rigid and confusing for new developers or when handling multiple inputs.
That is where Laravel Prompts comes in. By integrating Artisan Commands with Laravel Prompts, you can transform your console interactions into an engaging and user-friendly experience. Laravel Prompts allows you to create dynamic command-line interfaces with structured inputs, progress bars, tables, and more. This makes it easier for users to provide accurate data while improving the overall experience.
What Are Prompts in Laravel
Laravel Prompts is an official package in the Laravel ecosystem that makes Artisan commands interactive and user friendly. It allows developers to create command-line interfaces with inputs, confirmations, tables, and progress bars. By using Artisan Commands with Laravel Prompts, you can collect data more efficiently and guide users through each step without relying on plain text input.
Why User-Friendly Artisan Commands Matter
User-friendly Artisan commands play a key role in improving productivity and reducing errors during development. When commands are clear, interactive, and easy to follow, developers can complete complex tasks faster without memorizing multiple options or arguments. By using Artisan Commands with Laravel Prompts, you make the command-line experience intuitive and accessible, even for new team members.
Getting Started with Laravel Prompts
Before you can start enhancing your Artisan commands, you need to install the Laravel Prompts package. Since it is an official Laravel package, the installation process is simple and quick. Run the following command in your project directory:
composer require laravel/prompts
Once installed, you can immediately use Artisan Commands with Laravel Prompts in your custom commands. Laravel registers the package automatically, so you only need to import the classes and start building interactive, user-friendly CLI experiences.
Common Types of Prompts in Laravel Prompts
Laravel Prompts provides several types of inputs and interactive elements to make Artisan Commands with Laravel Prompts more user-friendly. Here’s an overview of the most common types with examples.
Text Inputs
Used to collect string data from the user. You can add default values or validations.
use function Laravel\Prompts\text;
$name = text('Enter your name:');
Secret Inputs
Used for sensitive data like passwords. Input is hidden while typing.
use function Laravel\Prompts\password;
$password = password('Enter your password:');
Select Options
Allows users to choose from a list of predefined options.
use function Laravel\Prompts\select;
$role = select(
label: 'What role should the user have?',
options: ['Member', 'Contributor', 'Owner']
);
Confirmation
Used to get a yes/no response from the user.
use function Laravel\Prompts\confirm;
$proceed = confirm('Do you want to continue?', default: true);
Table
Displays data in a structured table format in the terminal.
use function Laravel\Prompts\table;
$users = [
[1, 'John', 'john@example.com', 'Admin'],
[2, 'Jane', 'jane@example.com', 'Editor'],
];
table(['ID', 'Name', 'Email', 'Role'], $users);
Progress
The progress shows task completion in real time, helping users track long-running operations like data imports or loops.
use function Laravel\Prompts\progress;
progress(
label: 'Processing items...',
steps: 5,
callback: function ($step, $progress) {
sleep(1);
$progress->advance();
}
);
Spin
Indicates ongoing processes when tasks take time to complete.
use function Laravel\Prompts\spin;
$response = spin(
callback: fn () => Http::get('http://example.com'),
message: 'Fetching response...'
);
Messages & Notifications
Messages display information, warnings, or errors in a clear, styled format to guide users during command execution.
use function Laravel\Prompts\info;
use function Laravel\Prompts\error;
use function Laravel\Prompts\alert;
info('Package installed successfully.');
error('Something went wrong.');
alert('Details not found.');
Clearing Terminal
You can clear the terminal screen to keep the interface clean.
use function Laravel\Prompts\clear;
clear();
These elements let you build interactive Artisan Commands with Laravel Prompts that are easy to use, visually clear, and guide users step by step.
Example: Creating a User with Prompts
In this example, we will create a simple Artisan command to add a new user using Artisan Commands with Laravel Prompts. The command will guide the user step by step, collect input with different prompt types, show progress, and display the created users in a table.
To create new artisan command open your terminal and enter below command:
php artisan make:command CreateUser
Command will create new artisan command file CreateUser.php. Open it and modify as below:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use function Laravel\Prompts\{text, password, confirm, select, multiselect, info, alert, progress};
class CreateUser extends Command
{
protected $signature = 'app:create-user';
protected $description = 'Create a new user with interactive prompts';
/**
* Execute the console command.
*/
public function handle()
{
info('Welcome to User Creation Wizard! Please follow the prompts.');
$steps = ['Name', 'Email', 'Password', 'Role', 'Permissions'];
$currentStep = 0;
$results = progress(
label: 'Getting user details',
steps: $steps,
callback: function ($step, $progress)
use (&$currentStep) {
$currentStep++;
return match ($step) {
'Name' => text(label: 'Enter user name', required: true),
'Email' => $email = text(
label: 'Enter user email',
required: true,
validate: fn(string $value) => filter_var($value, FILTER_VALIDATE_EMAIL) ? null : 'Invalid email format'
),
'Password' => password(label: 'Set user password', required: true),
'Role' => select(label: 'Select user role', options: ['User', 'Admin', 'Manager'], required: true),
'Permissions' => multiselect(label: 'Select permissions', options: ['Read', 'Write', 'Update', 'Delete']),
};
}
);
[$name, $email, $password, $role, $permissions] = $results;
$confirmed = confirm(label: 'Confirm creation of this user?');
if (!$confirmed) {
alert('User creation cancelled!');
return Command::FAILURE;
}
alert("User '{$name}' created successfully!");
$users = [
['ID' => 1, 'Name' => 'Alice', 'Email' => 'alice@example.com', 'Role' => 'Admin'],
['ID' => 2, 'Name' => 'Bob', 'Email' => 'bob@example.com', 'Role' => 'User'],
['ID' => 3, 'Name' => 'Charlie', 'Email' => 'charlie@example.com', 'Role' => 'Manager'],
['ID' => 4, 'Name' => 'David', 'Email' => 'david@example.com', 'Role' => 'User'],
['ID' => 5, 'Name' => 'Eve', 'Email' => 'eve@example.com', 'Role' => 'User'],
];
$users[] = ['ID' => 11, 'Name' => $name, 'Email' => $email, 'Role' => $role];
$this->table(
['ID', 'Name', 'Email', 'Role'],
array_slice($users, -5)
);
return Command::SUCCESS;
}
}
In above example, it will include almost all common things like form with different types of input, progress, and table. Here, we have created command to add user and show table of users. We haven’t implemented data operation here for better understanding but you can perform insert into database as well as showing table data from users table.

As you can see in output image here it will ask user details one by one and show progress with each input and at end of script it will show success message and table containing new user details.
Conclusion
Enhancing Artisan Commands with Laravel Prompts with proper validations and customizations ensures commands are user-friendly, reliable, and professional. By combining clear input rules, real-time feedback, and interactive elements like spinners and progress bars, you can significantly improve the command-line experience. Implementing these practices makes your Laravel commands more intuitive and practical for real-world applications.
AnsiKit is a core PHP library for enhancing command-line UIs, similar to Laravel Prompts. While Laravel Prompts focuses on beautiful and user-friendly input forms for Artisan commands, AnsiKit provides low-level components for building rich terminal interfaces in pure PHP, including colors, tables, and interactive elements. It’s a great choice for developers looking to enhance PHP CLI tools outside of the Laravel ecosystem.