Methods |
public
static
|
getDefaultName(): string|null
|
#
|
public
static
|
getDefaultDescription(): ?string
|
#
|
public
|
__construct(string|null $name = null)
Parameters
$name |
The name of the command; passing null means it must be set in configure()
|
Throws
Overriden by
|
#
|
public
|
ignoreValidationErrors()
Ignores validation errors.
Ignores validation errors.
This is mainly useful for the help command.
|
#
|
public
|
setApplication(Application $application = null)
|
#
|
public
|
setHelperSet(HelperSet $helperSet)
|
#
|
public
|
getHelperSet(): HelperSet|null
Gets the helper set.
|
#
|
public
|
getApplication(): Application|null
Gets the application instance for this command.
Gets the application instance for this command.
|
#
|
public
|
isEnabled(): bool
Checks whether the command is enabled or not in the current environment.
Checks whether the command is enabled or not in the current environment.
Override this to check for x or y and return false if the command cannot
run properly under the current conditions.
|
#
|
public
|
run(InputInterface $input, OutputInterface $output): int
Runs the command.
Runs the command.
The code to execute is either defined directly with the
setCode() method or by overriding the execute() method
in a sub-class.
Returns
Throws
Overriden by
|
#
|
public
|
complete(CompletionInput $input, CompletionSuggestions $suggestions): void
Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
|
#
|
public
|
setCode(callable $code): $this
Sets the code to execute when running this command.
Sets the code to execute when running this command.
If this method is used, it overrides the code defined
in the execute() method.
Parameters
$code |
A callable(InputInterface $input, OutputInterface $output)
|
Throws
|
#
|
public
|
setDefinition(array|InputDefinition $definition): $this
Sets an array of argument and option instances.
Sets an array of argument and option instances.
Parameters
$definition |
An array of argument and option instances or a definition instance
|
|
#
|
public
|
getDefinition(): InputDefinition
Gets the InputDefinition attached to this Command.
Gets the InputDefinition attached to this Command.
|
#
|
public
|
getNativeDefinition(): InputDefinition
Gets the InputDefinition to be used to create representations of this Command.
Gets the InputDefinition to be used to create representations of this Command.
Can be overridden to provide the original command representation when it would otherwise
be changed by merging with the application InputDefinition.
This method is not part of public API and should not be used directly.
|
#
|
public
|
addArgument(string $name, int|null $mode = null, string $description = '', mixed $default = null): $this
Adds an argument.
Parameters
$mode |
The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
|
$default |
The default value (for InputArgument::OPTIONAL mode only)
|
Throws
|
#
|
public
|
addOption(
string $name,
string|array|null $shortcut = null,
int|null $mode = null,
string $description = '',
mixed $default = null,
): $this
Adds an option.
Parameters
$shortcut |
The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
$mode |
The option mode: One of the InputOption::VALUE_* constants
|
$default |
The default value (must be null for InputOption::VALUE_NONE)
|
Throws
|
#
|
public
|
setName(string $name): $this
Sets the name of the command.
Sets the name of the command.
This method can set both the namespace and the name if
you separate them by a colon (:)
$command->setName('foo:bar');
Throws
|
#
|
public
|
setProcessTitle(string $title): $this
Sets the process title of the command.
Sets the process title of the command.
This feature should be used only when creating a long process command,
like a daemon.
|
#
|
public
|
getName(): string|null
Returns the command name.
Returns the command name.
|
#
|
public
|
setHidden(bool $hidden): $this
Parameters
$hidden |
Whether or not the command should be hidden from the list of commands
The default value will be true in Symfony 6.0
|
Overriden by
|
#
|
public
|
isHidden(): bool
Returns
whether the command should be publicly shown or not
Overriden by
|
#
|
public
|
setDescription(string $description): $this
Sets the description for the command.
Sets the description for the command.
|
#
|
public
|
getDescription(): string
Returns the description for the command.
Returns the description for the command.
|
#
|
public
|
setHelp(string $help): $this
Sets the help for the command.
Sets the help for the command.
|
#
|
public
|
getHelp(): string
Returns the help for the command.
Returns the help for the command.
|
#
|
public
|
getProcessedHelp(): string
Returns the processed help for the command replacing the %command.name% and
%command.full_name% patterns with the real…
Returns the processed help for the command replacing the %command.name% and
%command.full_name% patterns with the real values dynamically.
|
#
|
public
|
setAliases(string[] $aliases): $this
Sets the aliases for the command.
Sets the aliases for the command.
Parameters
$aliases |
An array of aliases for the command
|
Throws
|
#
|
public
|
getAliases(): array
Returns the aliases for the command.
Returns the aliases for the command.
|
#
|
public
|
getSynopsis(bool $short = false): string
Returns the synopsis for the command.
Returns the synopsis for the command.
Parameters
$short |
Whether to show the short version of the synopsis (with options folded) or not
|
|
#
|
public
|
addUsage(string $usage): $this
Add a command usage example, it'll be prefixed with the command name.
Add a command usage example, it'll be prefixed with the command name.
|
#
|
public
|
getUsages(): array
Returns alternative usages of the command.
Returns alternative usages of the command.
|
#
|
public
|
getHelper(string $name): mixed
Gets a helper instance by name.
Gets a helper instance by name.
Throws
|
#
|