$defaultName
$defaultName : string|null
ListCommand displays the list of all available commands for the application.
$hidden :
setApplication(\Symfony\Component\Console\Application $application = null)
\Symfony\Component\Console\Application | $application |
setHelperSet(\Symfony\Component\Console\Helper\HelperSet $helperSet)
\Symfony\Component\Console\Helper\HelperSet | $helperSet |
getHelperSet() : \Symfony\Component\Console\Helper\HelperSet
Gets the helper set.
A HelperSet instance
getApplication() : \Symfony\Component\Console\Application
Gets the application instance for this command.
An Application instance
run(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) : integer
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.
\Symfony\Component\Console\Input\InputInterface | $input | |
\Symfony\Component\Console\Output\OutputInterface | $output |
When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}.
The command exit code
setCode(callable $code) : $this
Sets the code to execute when running this command.
If this method is used, it overrides the code defined in the execute() method.
callable | $code | A callable(InputInterface $input, OutputInterface $output) |
mergeApplicationDefinition(boolean $mergeArgs = true)
Merges the application definition with the command definition.
This method is not part of public API and should not be used directly.
boolean | $mergeArgs | Whether to merge or not the Application definition arguments to Command definition arguments |
setDefinition(array|\Symfony\Component\Console\Input\InputDefinition $definition) : $this
Sets an array of argument and option instances.
array|\Symfony\Component\Console\Input\InputDefinition | $definition | An array of argument and option instances or a definition instance |
getDefinition() : \Symfony\Component\Console\Input\InputDefinition
Gets the InputDefinition attached to this Command.
An InputDefinition instance
getNativeDefinition() : \Symfony\Component\Console\Input\InputDefinition
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.
An InputDefinition instance
addArgument(string $name, integer|null $mode = null, string $description = '', string|array<mixed,string>|null $default = null) : $this
Adds an argument.
string | $name | The argument name |
integer|null | $mode | The argument mode: self::REQUIRED or self::OPTIONAL |
string | $description | A description text |
string|array<mixed,string>|null | $default | The default value (for self::OPTIONAL mode only) |
When argument mode is not valid
addOption(string $name, string|array $shortcut = null, integer|null $mode = null, string $description = '', string|array<mixed,string>|boolean|null $default = null) : $this
Adds an option.
string | $name | The option name |
string|array | $shortcut | The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts |
integer|null | $mode | The option mode: One of the VALUE_* constants |
string | $description | A description text |
string|array<mixed,string>|boolean|null | $default | The default value (must be null for self::VALUE_NONE) |
If option mode is invalid or incompatible
setName(string $name) : $this
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');
string | $name | The command name |
When the name is invalid
setHidden(boolean $hidden) : \Symfony\Component\Console\Command\Command
boolean | $hidden | Whether or not the command should be hidden from the list of commands |
The current instance
getHelper(string $name) : mixed
Gets a helper instance by name.
string | $name | The helper name |
if no HelperSet is defined
if the helper is not defined
The helper value
execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) : integer|null
Executes the current command.
This method is not abstract because you can use this class as a concrete class. In this case, instead of defining the execute() method, you set the code to execute by passing a Closure to the setCode() method.
\Symfony\Component\Console\Input\InputInterface | $input | |
\Symfony\Component\Console\Output\OutputInterface | $output |
null or 0 if everything went fine, or an error code
interact(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
Interacts with the user.
This method is executed before the InputDefinition is validated. This means that this is the only place where the command can interactively ask for values of missing required arguments.
\Symfony\Component\Console\Input\InputInterface | $input | |
\Symfony\Component\Console\Output\OutputInterface | $output |
initialize(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
Initializes the command after the input has been bound and before the input is validated.
This is mainly useful when a lot of commands extends one main command where some things need to be initialized based on the input arguments and options.
\Symfony\Component\Console\Input\InputInterface | $input | |
\Symfony\Component\Console\Output\OutputInterface | $output |
validateName(\Symfony\Component\Console\Command\string $name)
Validates a command name.
It must be non-empty and parts can optionally be separated by ":".
\Symfony\Component\Console\Command\string | $name |
When the name is invalid