trait InteractsWithIO

Properties

protected Factory|null $components

The console components factory.

protected InputInterface|null $input
protected OutputStyle|null $output
protected int $verbosity

The default verbosity of output commands.

protected array $verbosityMap

The mapping between human readable verbosity levels and Symfony's OutputInterface.

Methods

mixed
input(string|null $key = null, mixed $default = null)

Retrieve the command's input as a CommandInput instance or retrieve an input item.

bool
hasArgument(int|string $name)

Determine if the given argument is present.

mixed
argument(string|null $key = null)

Get the value of a command argument.

array
arguments()

Get all of the arguments passed to the command.

bool
hasOption(string $name)

Determine if the given option is present.

mixed
option(string|null $key = null)

Get the value of a command option.

array
options()

Get all of the options passed to the command.

bool
confirm(string $question, bool $default = false)

Confirm a question with the user.

mixed
ask(string $question, string|null $default = null)

Prompt the user for input.

mixed
anticipate(string $question, iterable|callable $choices, string|null $default = null)

Prompt the user for input with auto completion.

mixed
askWithCompletion(string $question, iterable|callable $choices, string|null $default = null)

Prompt the user for input with auto completion.

mixed
secret(string $question, bool $fallback = true)

Prompt the user for input but hide the answer from the console.

array|string
choice(string $question, array $choices, int|string|null $default = null, int|null $attempts = null, bool $multiple = false)

Give the user a single choice from an array of answers.

void
table(array $headers, array|Arrayable $rows, string|TableStyle $tableStyle = 'default', array $columnStyles = [])

Format input to textual table.

mixed
withProgressBar(iterable|int $totalSteps, Closure $callback)

Execute a given callback while advancing a progress bar.

void
info(string $string, int|string|null $verbosity = null)

Write a string as information output.

void
line(string $string, string|null $style = null, int|string|null $verbosity = null)

Write a string as standard output.

void
comment(string $string, int|string|null $verbosity = null)

Write a string as comment output.

void
question(string $string, int|string|null $verbosity = null)

Write a string as question output.

void
error(string $string, int|string|null $verbosity = null)

Write a string as error output.

void
warn(string $string, int|string|null $verbosity = null)

Write a string as warning output.

void
alert(string $string, int|string|null $verbosity = null)

Write a string in an alert box.

newLine(int $count = 1)

Write a blank line.

void
setInput(InputInterface $input)

Set the input interface implementation.

void
setOutput(OutputStyle $output)

Set the output interface implementation.

getOutput()

Get the output implementation.

Factory|null
outputComponents()

Get the output component factory implementation.

void
setVerbosity(int|string $level)

Set the verbosity level.

int
parseVerbosity(int|string|null $level = null)

Get the verbosity level in terms of Symfony's OutputInterface level.

Details

at line 53
mixed input(string|null $key = null, mixed $default = null)

Retrieve the command's input as a CommandInput instance or retrieve an input item.

Parameters

string|null $key
mixed $default

Return Value

mixed

at line 63
bool hasArgument(int|string $name)

Determine if the given argument is present.

Parameters

int|string $name

Return Value

bool

at line 71
mixed argument(string|null $key = null)

Get the value of a command argument.

Parameters

string|null $key

Return Value

mixed

at line 83
array arguments()

Get all of the arguments passed to the command.

Return Value

array

at line 91
bool hasOption(string $name)

Determine if the given option is present.

Parameters

string $name

Return Value

bool

at line 99
mixed option(string|null $key = null)

Get the value of a command option.

Parameters

string|null $key

Return Value

mixed

at line 111
array options()

Get all of the options passed to the command.

Return Value

array

at line 119
bool confirm(string $question, bool $default = false)

Confirm a question with the user.

Parameters

string $question
bool $default

Return Value

bool

at line 127
mixed ask(string $question, string|null $default = null)

Prompt the user for input.

Parameters

string $question
string|null $default

Return Value

mixed

at line 135
mixed anticipate(string $question, iterable|callable $choices, string|null $default = null)

Prompt the user for input with auto completion.

Parameters

string $question
iterable|callable $choices
string|null $default

Return Value

mixed

at line 143
mixed askWithCompletion(string $question, iterable|callable $choices, string|null $default = null)

Prompt the user for input with auto completion.

Parameters

string $question
iterable|callable $choices
string|null $default

Return Value

mixed

at line 157
mixed secret(string $question, bool $fallback = true)

Prompt the user for input but hide the answer from the console.

Parameters

string $question
bool $fallback

Return Value

mixed

at line 169
array|string choice(string $question, array $choices, int|string|null $default = null, int|null $attempts = null, bool $multiple = false)

Give the user a single choice from an array of answers.

Parameters

string $question
array $choices
int|string|null $default
int|null $attempts
bool $multiple

Return Value

array|string

at line 181
void table(array $headers, array|Arrayable $rows, string|TableStyle $tableStyle = 'default', array $columnStyles = [])

Format input to textual table.

Parameters

array $headers
array|Arrayable $rows
string|TableStyle $tableStyle
array $columnStyles

Return Value

void

at line 201
mixed withProgressBar(iterable|int $totalSteps, Closure $callback)

Execute a given callback while advancing a progress bar.

Parameters

iterable|int $totalSteps
Closure $callback

Return Value

mixed

at line 231
void info(string $string, int|string|null $verbosity = null)

Write a string as information output.

Parameters

string $string
int|string|null $verbosity

Return Value

void

at line 239
void line(string $string, string|null $style = null, int|string|null $verbosity = null)

Write a string as standard output.

Parameters

string $string
string|null $style
int|string|null $verbosity

Return Value

void

at line 249
void comment(string $string, int|string|null $verbosity = null)

Write a string as comment output.

Parameters

string $string
int|string|null $verbosity

Return Value

void

at line 257
void question(string $string, int|string|null $verbosity = null)

Write a string as question output.

Parameters

string $string
int|string|null $verbosity

Return Value

void

at line 265
void error(string $string, int|string|null $verbosity = null)

Write a string as error output.

Parameters

string $string
int|string|null $verbosity

Return Value

void

at line 273
void warn(string $string, int|string|null $verbosity = null)

Write a string as warning output.

Parameters

string $string
int|string|null $verbosity

Return Value

void

at line 287
void alert(string $string, int|string|null $verbosity = null)

Write a string in an alert box.

Parameters

string $string
int|string|null $verbosity

Return Value

void

at line 301
InteractsWithIO newLine(int $count = 1)

Write a blank line.

Parameters

int $count

Return Value

InteractsWithIO

at line 311
void setInput(InputInterface $input)

Set the input interface implementation.

Parameters

InputInterface $input

Return Value

void

at line 319
void setOutput(OutputStyle $output)

Set the output interface implementation.

Parameters

OutputStyle $output

Return Value

void

at line 327
OutputStyle|null getOutput()

Get the output implementation.

Return Value

OutputStyle|null

at line 335
Factory|null outputComponents()

Get the output component factory implementation.

Return Value

Factory|null

at line 343
protected void setVerbosity(int|string $level)

Set the verbosity level.

Parameters

int|string $level

Return Value

void

at line 351
protected int parseVerbosity(int|string|null $level = null)

Get the verbosity level in terms of Symfony's OutputInterface level.

Parameters

int|string|null $level

Return Value

int