Properties

$defaultName

$defaultName : string|null

Type

string|null — The default command name

$application

$application : 

Type

$name

$name : 

Type

$processTitle

$processTitle : 

Type

$aliases

$aliases : 

Type

$definition

$definition : 

Type

$hidden

$hidden : 

Type

$help

$help : 

Type

$description

$description : 

Type

$ignoreValidationErrors

$ignoreValidationErrors : 

Type

$applicationDefinitionMerged

$applicationDefinitionMerged : 

Type

$applicationDefinitionMergedWithArgs

$applicationDefinitionMergedWithArgs : 

Type

$code

$code : 

Type

$synopsis

$synopsis : 

Type

$usages

$usages : 

Type

$helperSet

$helperSet : 

Type

Methods

getComposer()

getComposer(boolean  $required = true, boolean|null  $disablePlugins = null) : \Composer\Composer

Parameters

boolean $required
boolean|null $disablePlugins

Throws

\RuntimeException

Returns

\Composer\Composer

setComposer()

setComposer(\Composer\Composer  $composer) 

Parameters

\Composer\Composer $composer

resetComposer()

resetComposer() 

Removes the cached composer instance

isProxyCommand()

isProxyCommand() : boolean

Whether or not this command is meant to call another command.

This is mainly needed to avoid duplicated warnings messages.

Returns

boolean

getDefaultName()

getDefaultName() : string|null

Returns

string|null —

The default command name or null when no default name is set

__construct()

__construct(string|null  $name = null) 

Parameters

string|null $name

The name of the command; passing null means it must be set in configure()

Throws

\Symfony\Component\Console\Exception\LogicException

When the command name is empty

ignoreValidationErrors()

ignoreValidationErrors() 

Ignores validation errors.

This is mainly useful for the help command.

getApplication()

getApplication() : \Symfony\Component\Console\Application

Gets the application instance for this command.

Returns

\Symfony\Component\Console\Application

An Application instance

isEnabled()

isEnabled() : boolean

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.

Returns

boolean

run()

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.

Parameters

\Symfony\Component\Console\Input\InputInterface $input
\Symfony\Component\Console\Output\OutputInterface $output

Throws

\Exception

When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}.

Returns

integer —

The command exit code

setCode()

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.

Parameters

callable $code

A callable(InputInterface $input, OutputInterface $output)

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

Returns

$this

mergeApplicationDefinition()

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.

Parameters

boolean $mergeArgs

Whether to merge or not the Application definition arguments to Command definition arguments

setDefinition()

setDefinition(array|\Symfony\Component\Console\Input\InputDefinition  $definition) : $this

Sets an array of argument and option instances.

Parameters

array|\Symfony\Component\Console\Input\InputDefinition $definition

An array of argument and option instances or a definition instance

Returns

$this

getNativeDefinition()

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.

Returns

\Symfony\Component\Console\Input\InputDefinition

An InputDefinition instance

addArgument()

addArgument(string  $name, integer|null  $mode = null, string  $description = '', string|array<mixed,string>|null  $default = null) : $this

Adds an argument.

Parameters

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)

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

When argument mode is not valid

Returns

$this

addOption()

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.

Parameters

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)

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

If option mode is invalid or incompatible

Returns

$this

setName()

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');

Parameters

string $name

The command name

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

When the name is invalid

Returns

$this

setProcessTitle()

setProcessTitle(string  $title) : $this

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

Parameters

string $title

The process title

Returns

$this

getName()

getName() : string

Returns the command name.

Returns

string —

The command name

setHidden()

setHidden(boolean  $hidden) : \Symfony\Component\Console\Command\Command

Parameters

boolean $hidden

Whether or not the command should be hidden from the list of commands

Returns

\Symfony\Component\Console\Command\Command

The current instance

isHidden()

isHidden() : boolean

Returns

boolean —

whether the command should be publicly shown or not

setDescription()

setDescription(string  $description) : $this

Sets the description for the command.

Parameters

string $description

The description for the command

Returns

$this

getDescription()

getDescription() : string

Returns the description for the command.

Returns

string —

The description for the command

setHelp()

setHelp(string  $help) : $this

Sets the help for the command.

Parameters

string $help

The help for the command

Returns

$this

getHelp()

getHelp() : string

Returns the help for the command.

Returns

string —

The help for the command

getProcessedHelp()

getProcessedHelp() : string

Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.

Returns

string —

The processed help for the command

setAliases()

setAliases(array<mixed,string>  $aliases) : $this

Sets the aliases for the command.

Parameters

array<mixed,string> $aliases

An array of aliases for the command

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

When an alias is invalid

Returns

$this

getAliases()

getAliases() : array

Returns the aliases for the command.

Returns

array —

An array of aliases for the command

getSynopsis()

getSynopsis(boolean  $short = false) : string

Returns the synopsis for the command.

Parameters

boolean $short

Whether to show the short version of the synopsis (with options folded) or not

Returns

string —

The synopsis

addUsage()

addUsage(string  $usage) : $this

Add a command usage example.

Parameters

string $usage

The usage, it'll be prefixed with the command name

Returns

$this

getUsages()

getUsages() : array

Returns alternative usages of the command.

Returns

array

getHelper()

getHelper(string  $name) : mixed

Gets a helper instance by name.

Parameters

string $name

The helper name

Throws

\Symfony\Component\Console\Exception\LogicException

if no HelperSet is defined

\Symfony\Component\Console\Exception\InvalidArgumentException

if the helper is not defined

Returns

mixed —

The helper value

initialize()

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.

Parameters

\Symfony\Component\Console\Input\InputInterface $input
\Symfony\Component\Console\Output\OutputInterface $output

getPreferredInstallOptions()

getPreferredInstallOptions(\Composer\Config  $config, \Symfony\Component\Console\Input\InputInterface  $input, boolean  $keepVcsRequiresPreferSource = false) : array<mixed,boolean>

Returns preferSource and preferDist values based on the configuration.

Parameters

\Composer\Config $config
\Symfony\Component\Console\Input\InputInterface $input
boolean $keepVcsRequiresPreferSource

Returns

array<mixed,boolean> —

An array composed of the preferSource and preferDist values

configure()

configure() 

validateName()

validateName(\Symfony\Component\Console\Command\string  $name) 

Validates a command name.

It must be non-empty and parts can optionally be separated by ":".

Parameters

\Symfony\Component\Console\Command\string $name

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

When the name is invalid