Command
abstract class Command extends Command (View source)
Concrete5 base command class Large swaths of this class have been copied from illuminate/config 5.2 and 5.5 so you may refer to their documentation for some things.
Constants
RETURN_CODE_ON_FAILURE |
The return code we should return when an exception is thrown while running the command. |
ALLOWASROOT_OPTION |
The name of the CLI option that allows running CLI commands as root without confirmation. |
ALLOWASROOT_ENV |
The name of the environment variable that allows running CLI commands as root without confirmation. |
Properties
protected InputInterface | $input | ||
protected OutputStyle | $output | ||
protected string | $name | ||
protected string | $description | ||
$hidden | |||
protected string | $signature | The command signature |
|
protected bool | $canRunAsRoot | Can this command be executed as root? If set to false, the command can be executed if one of these conditions is satisfied:
|
Methods
No description
Configure the console command using a fluent definition.
Specify the arguments and options on the command.
Get the arguments for this command
Get the options for this command
{@inheritdoc}
{@inheritdoc}
Add the "env" option to the command options.
Allow/disallow running this command as root without confirmation.
Is the current user root?
No description
This method is overridden to pipe execution to the handle method hiding input and output
Call another console command.
Call another console command silently.
Determine if the given argument is present.
Get the value of a command argument.
Get all of the arguments passed to the command.
Determine if the given option is present.
Get the value of a command option.
Get all of the options passed to the command.
Confirm a question with the user.
Prompt the user for input.
Prompt the user for input with auto completion.
Prompt the user for input but hide the answer from the console.
Give the user a single choice from an array of answers.
Format input to textual table.
No description
Details
__construct($name = null)
No description
protected void
configureUsingFluentDefinition()
Configure the console command using a fluent definition.
protected void
specifyParameters()
Specify the arguments and options on the command.
protected array
getArguments()
Get the arguments for this command
If $this->signature is specified, this method has no effect.
protected array
getOptions()
Get the options for this command
If $this->signature is specified, this method has no effect.
run(InputInterface $input, OutputInterface $output)
{@inheritdoc}
protected
initialize(InputInterface $input, OutputInterface $output)
{@inheritdoc}
protected
writeError(OutputInterface $output, Exception|Throwable $error)
deprecated
deprecated
Write an exception.
protected Command
addEnvOption()
Add the "env" option to the command options.
protected $this
setCanRunAsRoot(bool $canRunAsRoot)
Allow/disallow running this command as root without confirmation.
protected bool|null
isRunningAsRoot()
Is the current user root?
protected
confirmRunningAsRoot(InputInterface $input, OutputInterface $output)
No description
protected mixed
execute(InputInterface $input, OutputInterface $output)
This method is overridden to pipe execution to the handle method hiding input and output
int
call(string $command, array $arguments = [])
Call another console command.
int
callSilent(string $command, array $arguments = [])
Call another console command silently.
bool
hasArgument(string|int $name)
Determine if the given argument is present.
string|array
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.
string|array
option(string $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.
string
ask(string $question, string $default = null)
Prompt the user for input.
string
askWithCompletion(string $question, array $choices, string $default = null, null $attempts = null, null $strict = null)
Prompt the user for input with auto completion.
string
secret(string $question, bool $fallback = true)
Prompt the user for input but hide the answer from the console.
string
choice(string $question, array $choices, string $default = null, mixed $attempts = null, bool $multiple = null)
Give the user a single choice from an array of answers.
void
table(array $headers, array $rows, string $tableStyle = 'default', array $columnStyles = [])
Format input to textual table.
Application|Application
getApplication()
No description