Skip to content

[13.x] Add input() method to console commands#60607

Merged
taylorotwell merged 6 commits into
laravel:13.xfrom
stevebauman:command-input
Jun 30, 2026
Merged

[13.x] Add input() method to console commands#60607
taylorotwell merged 6 commits into
laravel:13.xfrom
stevebauman:command-input

Conversation

@stevebauman

@stevebauman stevebauman commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description:

This PR adds an input() method to console commands that returns a CommandInput instance, giving you the same fluent, typed data accessors available on Request, ValidatedInput, and Fluent instances ($request->enum('...'), date(), integer(), string(), boolean(), collect(), etc.) when working with a command's arguments and options.

The CommandInput instance contains all of the command's arguments and options merged together, with arguments taking precedence when keys collide. You may also access them independently via the $input->arguments() and $input->options() methods if necessary.

Example:

use App\Enums\ReportType;
use Illuminate\Console\Command;

class GenerateReport extends Command
{
    protected $signature = 'report:generate {type} {--from=} {--to=}';

    public function handle(): void
    {
        $input = $this->input();

        $type = $input->enum('type', ReportType::class);
        $from = $input->date('from');
        $to = $input->date('to');

        // Generate the report...
    }
}

Let me know your thoughts! ❤️

@taylorotwell taylorotwell merged commit 40efd71 into laravel:13.x Jun 30, 2026
53 checks passed
@taylorotwell

Copy link
Copy Markdown
Member

Thanks!

brecht-vermeersch pushed a commit to brecht-vermeersch/framework that referenced this pull request Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants