Command
class Command
Base class for all commands.
Methods
Constructor.
Ignores validation errors.
Gets the helper set.
Gets the application instance for this command.
Checks whether the command is enabled or not in the current environment.
Merges the application definition with the command definition.
Gets the InputDefinition attached to this Command.
Gets the InputDefinition to be used to create representations of this Command.
Adds an argument.
Adds an option.
Sets the process title of the command.
Returns the command name.
Sets the description for the command.
Returns the description for the command.
Returns the help for the command.
Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
Sets the aliases for the command.
Returns the aliases for the command.
Returns the synopsis for the command.
Add a command usage example.
Returns alternative usages of the command.
Gets a helper instance by name.
Details
at line line 54
__construct(string|null $name = null)
Constructor.
at line line 74
ignoreValidationErrors()
Ignores validation errors.
This is mainly useful for the help command.
at line line 84
setApplication(Application $application = null)
Sets the application instance for this command.
at line line 99
setHelperSet(HelperSet $helperSet)
Sets the helper set.
at line line 109
HelperSet
getHelperSet()
Gets the helper set.
at line line 119
Application
getApplication()
Gets the application instance for this command.
at line line 132
bool
isEnabled()
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 can not run properly under the current conditions.
at line line 210
int
run(InputInterface $input, OutputInterface $output)
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.
at line line 276
Command
setCode(callable $code)
Sets the code to execute when running this command.
If this method is used, it overrides the code defined in the execute() method.
at line line 297
mergeApplicationDefinition(bool $mergeArgs = true)
Merges the application definition with the command definition.
This method is not part of public API and should not be used directly.
at line line 324
Command
setDefinition(array|InputDefinition $definition)
Sets an array of argument and option instances.
at line line 342
InputDefinition
getDefinition()
Gets the InputDefinition attached to this Command.
at line line 357
InputDefinition
getNativeDefinition()
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.
at line line 372
Command
addArgument(string $name, int $mode = null, string $description = '', mixed $default = null)
Adds an argument.
at line line 390
Command
addOption(string $name, string $shortcut = null, int $mode = null, string $description = '', mixed $default = null)
Adds an option.
at line line 411
Command
setName(string $name)
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');
at line line 432
Command
setProcessTitle(string $title)
Sets the process title of the command.
This feature should be used only when creating a long process command, like a daemon.
PHP 5.5+ or the proctitle PECL library is required
at line line 444
string
getName()
Returns the command name.
at line line 456
Command
setDescription(string $description)
Sets the description for the command.
at line line 468
string
getDescription()
Returns the description for the command.
at line line 480
Command
setHelp(string $help)
Sets the help for the command.
at line line 492
string
getHelp()
Returns the help for the command.
at line line 503
string
getProcessedHelp()
Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
at line line 528
Command
setAliases(string[] $aliases)
Sets the aliases for the command.
at line line 548
array
getAliases()
Returns the aliases for the command.
at line line 560
string
getSynopsis(bool $short = false)
Returns the synopsis for the command.
at line line 576
addUsage(string $usage)
Add a command usage example.
at line line 592
array
getUsages()
Returns alternative usages of the command.
at line line 606
mixed
getHelper(string $name)
Gets a helper instance by name.