Properties

$commands

$commands : 

Type

$wantHelps

$wantHelps : 

Type

$runningCommand

$runningCommand : 

Type

$name

$name : 

Type

$version

$version : 

Type

$commandLoader

$commandLoader : 

Type

$catchExceptions

$catchExceptions : 

Type

$autoExit

$autoExit : 

Type

$definition

$definition : 

Type

$helperSet

$helperSet : 

Type

$dispatcher

$dispatcher : 

Type

$terminal

$terminal : 

Type

$defaultCommand

$defaultCommand : 

Type

$singleCommand

$singleCommand : 

Type

$initialized

$initialized : 

Type

$logo

$logo : 

Type

$hasPluginCommands

$hasPluginCommands : 

Type

$disablePluginsByDefault

$disablePluginsByDefault : 

Type

Methods

__construct()

__construct() 

setDispatcher()

setDispatcher(\Symfony\Component\EventDispatcher\EventDispatcherInterface  $dispatcher) 

Parameters

\Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher

getHelperSet()

getHelperSet() : \Symfony\Component\Console\Helper\HelperSet

Get the helper set associated with the command.

Returns

\Symfony\Component\Console\Helper\HelperSet

The HelperSet instance associated with this command

getHelp()

getHelp() : string

Gets the help message.

Returns

string —

A help message

areExceptionsCaught()

areExceptionsCaught() : boolean

Gets whether to catch exceptions or not during commands execution.

Returns

boolean —

Whether to catch exceptions or not during commands execution

setCatchExceptions()

setCatchExceptions(boolean  $boolean) 

Sets whether to catch exceptions or not during commands execution.

Parameters

boolean $boolean

Whether to catch exceptions or not during commands execution

isAutoExitEnabled()

isAutoExitEnabled() : boolean

Gets whether to automatically exit after a command execution or not.

Returns

boolean —

Whether to automatically exit after a command execution or not

setAutoExit()

setAutoExit(boolean  $boolean) 

Sets whether to automatically exit after a command execution or not.

Parameters

boolean $boolean

Whether to automatically exit after a command execution or not

getName()

getName() : string

Gets the name of the application.

Returns

string —

The application name

setName()

setName(string  $name) 

Sets the application name.

Parameters

string $name

The application name

getVersion()

getVersion() : string

Gets the application version.

Returns

string —

The application version

setVersion()

setVersion(string  $version) 

Sets the application version.

Parameters

string $version

The application version

getLongVersion()

getLongVersion() : string

Returns the long version of the application.

Returns

string —

The long application version

register()

register(string  $name) : \Symfony\Component\Console\Command\Command

Registers a new command.

Parameters

string $name

The command name

Returns

\Symfony\Component\Console\Command\Command

The newly created command

addCommands()

addCommands(array<mixed,\Symfony\Component\Console\Command\Command>  $commands) 

Adds an array of command objects.

If a Command is not enabled it will not be added.

Parameters

array<mixed,\Symfony\Component\Console\Command\Command> $commands

An array of commands

add()

add(\Symfony\Component\Console\Command\Command  $command) : \Symfony\Component\Console\Command\Command|null

Adds a command object.

If a command with the same name already exists, it will be overridden. If the command is not enabled it will not be added.

Parameters

\Symfony\Component\Console\Command\Command $command

Returns

\Symfony\Component\Console\Command\Command|null —

The registered command if enabled or null

get()

get(string  $name) : \Symfony\Component\Console\Command\Command

Returns a registered command by name or alias.

Parameters

string $name

The command name or alias

Throws

\Symfony\Component\Console\Exception\CommandNotFoundException

When given command name does not exist

Returns

\Symfony\Component\Console\Command\Command

A Command object

has()

has(string  $name) : boolean

Returns true if the command exists, false otherwise.

Parameters

string $name

The command name or alias

Returns

boolean —

true if the command exists, false otherwise

getNamespaces()

getNamespaces() : array<mixed,string>

Returns an array of all unique namespaces used by currently registered commands.

It does not return the global namespace which always exists.

Returns

array<mixed,string> —

An array of namespaces

findNamespace()

findNamespace(string  $namespace) : string

Finds a registered namespace by a name or an abbreviation.

Parameters

string $namespace

A namespace or abbreviation to search for

Throws

\Symfony\Component\Console\Exception\NamespaceNotFoundException

When namespace is incorrect or ambiguous

Returns

string —

A registered namespace

find()

find(string  $name) : \Symfony\Component\Console\Command\Command

Finds a command by name or alias.

Contrary to get, this command tries to find the best match if you give it an abbreviation of a name or alias.

Parameters

string $name

A command name or a command alias

Throws

\Symfony\Component\Console\Exception\CommandNotFoundException

When command name is incorrect or ambiguous

Returns

\Symfony\Component\Console\Command\Command

A Command instance

all()

all(string  $namespace = null) : array<mixed,\Symfony\Component\Console\Command\Command>

Gets the commands (registered in the given namespace if provided).

The array keys are the full names and the values the command instances.

Parameters

string $namespace

A namespace name

Returns

array<mixed,\Symfony\Component\Console\Command\Command> —

An array of Command instances

getAbbreviations()

getAbbreviations(array  $names) : array

Returns an array of possible abbreviations given a set of names.

Parameters

array $names

An array of names

Returns

array —

An array of abbreviations

extractNamespace()

extractNamespace(string  $name, string  $limit = null) : string

Returns the namespace part of the command name.

This method is not part of public API and should not be used directly.

Parameters

string $name

The full name of the command

string $limit

The maximum number of parts of the namespace

Returns

string —

The namespace of the command

setDefaultCommand()

setDefaultCommand(string  $commandName, boolean  $isSingleCommand = false) : self

Sets the default Command name.

Parameters

string $commandName

The Command name

boolean $isSingleCommand

Set to true if there is only one command in this application

Returns

self

getComposer()

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

Parameters

boolean $required
boolean|null $disablePlugins

Throws

\Composer\Json\JsonValidationException

Returns

\Composer\Composer

resetComposer()

resetComposer() 

Removes the cached composer instance

doRunCommand()

doRunCommand(\Symfony\Component\Console\Command\Command  $command, \Symfony\Component\Console\Input\InputInterface  $input, \Symfony\Component\Console\Output\OutputInterface  $output) : integer

Runs the current command.

If an event dispatcher has been attached to the application, events are also dispatched during the life-cycle of the command.

Parameters

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

Returns

integer —

0 if everything went fine, or an error code

getCommandName()

getCommandName(\Symfony\Component\Console\Input\InputInterface  $input) : string

Gets the name of the command based on input.

Parameters

\Symfony\Component\Console\Input\InputInterface $input

Returns

string —

The command name

getDefaultCommands()

getDefaultCommands() : array<mixed,\Symfony\Component\Console\Command\Command>

Initializes all the composer commands.

Returns

array<mixed,\Symfony\Component\Console\Command\Command> —

An array of default Command instances

getDefaultHelperSet()

getDefaultHelperSet() : \Symfony\Component\Console\Helper\HelperSet

Gets the default helper set with the helpers that should always be available.

Returns

\Symfony\Component\Console\Helper\HelperSet

A HelperSet instance

getAbbreviationSuggestions()

getAbbreviationSuggestions(array  $abbrevs) : string

Returns abbreviated suggestions in string format.

Parameters

array $abbrevs

Abbreviated suggestions to convert

Returns

string —

A formatted string of abbreviated suggestions

findAlternatives()

findAlternatives(string  $name, \Symfony\Component\Console\iterable  $collection) : array<mixed,string>

Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs.

Parameters

string $name

The string

\Symfony\Component\Console\iterable $collection

The collection

Returns

array<mixed,string> —

A sorted array of similar string

splitStringByWidth()

splitStringByWidth(  $string,   $width) 

Parameters

$string
$width

extractAllNamespaces()

extractAllNamespaces(string  $name) : array<mixed,string>

Returns all namespaces of the command name.

Parameters

string $name

The full name of the command

Returns

array<mixed,string> —

The namespaces of the command

init()

init() 

hintCommonErrors()

hintCommonErrors(  $exception) 

{@inheritDoc}

Parameters

$exception

getPluginCommands()

getPluginCommands()