Documentation

Application extends Application
in package

An Application is the container for a collection of commands.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

$autoExit  : mixed
$catchExceptions  : mixed
$commandLoader  : mixed
$commands  : mixed
$commandsRegistered  : mixed
$defaultCommand  : mixed
$definition  : mixed
$dispatcher  : mixed
$helperSet  : mixed
$initialized  : mixed
$kernel  : mixed
$name  : mixed
$registrationErrors  : mixed
$runningCommand  : mixed
$signalRegistry  : mixed
$signalsToDispatchEvent  : mixed
$singleCommand  : mixed
$terminal  : mixed
$version  : mixed
$wantHelps  : mixed
__construct()  : mixed
add()  : Command|null
Adds a command object.
addCommands()  : mixed
Adds an array of command objects.
all()  : array<string|int, Command>
Gets the commands (registered in the given namespace if provided).
areExceptionsCaught()  : bool
Gets whether to catch exceptions or not during commands execution.
complete()  : void
Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
doRun()  : int
Runs the current application.
extractNamespace()  : string
Returns the namespace part of the command name.
find()  : Command
Finds a command by name or alias.
findNamespace()  : string
Finds a registered namespace by a name or an abbreviation.
get()  : Command
Returns a registered command by name or alias.
getAbbreviations()  : array<string|int, array<string|int, string>>
Returns an array of possible abbreviations given a set of names.
getDefinition()  : InputDefinition
Gets the InputDefinition related to this Application.
getHelp()  : string
Gets the help message.
getHelperSet()  : HelperSet
Get the helper set associated with the command.
getKernel()  : KernelInterface
Gets the Kernel associated with this Console.
getLongVersion()  : string
Returns the long version of the application.
getName()  : string
Gets the name of the application.
getNamespaces()  : array<string|int, string>
Returns an array of all unique namespaces used by currently registered commands.
getSignalRegistry()  : SignalRegistry
getVersion()  : string
Gets the application version.
has()  : bool
Returns true if the command exists, false otherwise.
isAutoExitEnabled()  : bool
Gets whether to automatically exit after a command execution or not.
register()  : Command
Registers a new command.
renderThrowable()  : void
reset()  : mixed
run()  : int
Runs the current application.
setAutoExit()  : mixed
Sets whether to automatically exit after a command execution or not.
setCatchExceptions()  : mixed
Sets whether to catch exceptions or not during commands execution.
setCommandLoader()  : mixed
setDefaultCommand()  : $this
Sets the default Command name.
setDefinition()  : mixed
setDispatcher()  : mixed
setHelperSet()  : mixed
setName()  : mixed
Sets the application name.
setSignalsToDispatchEvent()  : mixed
setVersion()  : mixed
Sets the application version.
configureIO()  : mixed
Configures the input and output instances based on the user arguments and options.
doRenderThrowable()  : void
doRunCommand()  : int
Runs the current command.
getCommandName()  : string|null
Gets the name of the command based on input.
getDefaultCommands()  : array<string|int, Command>
Gets the default commands that should always be available.
getDefaultHelperSet()  : HelperSet
Gets the default helper set with the helpers that should always be available.
getDefaultInputDefinition()  : InputDefinition
Gets the default input definition.
registerCommands()  : mixed
extractAllNamespaces()  : array<string|int, string>
Returns all namespaces of the command name.
findAlternatives()  : array<string|int, string>
Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs.
getAbbreviationSuggestions()  : string
Returns abbreviated suggestions in string format.
init()  : mixed
renderRegistrationErrors()  : mixed
splitStringByWidth()  : array<string|int, mixed>

Properties

$catchExceptions

private mixed $catchExceptions = true

$commandsRegistered

private mixed $commandsRegistered = false

$registrationErrors

private mixed $registrationErrors = []

$signalsToDispatchEvent

private mixed $signalsToDispatchEvent = []

Methods

add()

Adds a command object.

public add(Command $command) : Command|null

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
$command : Command
Return values
Command|null

addCommands()

Adds an array of command objects.

public addCommands(array<string|int, Command$commands) : mixed

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

Parameters
$commands : array<string|int, Command>

An array of commands

Return values
mixed

all()

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

public all([string|null $namespace = null ]) : array<string|int, Command>
Parameters
$namespace : string|null = null
Return values
array<string|int, Command>

areExceptionsCaught()

Gets whether to catch exceptions or not during commands execution.

public areExceptionsCaught() : bool
Return values
bool

extractNamespace()

Returns the namespace part of the command name.

public extractNamespace(string $name[, int|null $limit = null ]) : string

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

Parameters
$name : string
$limit : int|null = null
Return values
string

find()

Finds a command by name or alias.

public find(string $name) : Command
Parameters
$name : string
Return values
Command

findNamespace()

Finds a registered namespace by a name or an abbreviation.

public findNamespace(string $namespace) : string
Parameters
$namespace : string
Tags
throws
NamespaceNotFoundException

When namespace is incorrect or ambiguous

Return values
string

get()

Returns a registered command by name or alias.

public get(string $name) : Command
Parameters
$name : string
Return values
Command

getAbbreviations()

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

public static getAbbreviations(array<string|int, mixed> $names) : array<string|int, array<string|int, string>>
Parameters
$names : array<string|int, mixed>
Return values
array<string|int, array<string|int, string>>

getHelp()

Gets the help message.

public getHelp() : string
Return values
string

getLongVersion()

Returns the long version of the application.

public getLongVersion() : string
Return values
string

getName()

Gets the name of the application.

public getName() : string
Return values
string

getNamespaces()

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

public getNamespaces() : array<string|int, string>

It does not return the global namespace which always exists.

Return values
array<string|int, string>

getVersion()

Gets the application version.

public getVersion() : string
Return values
string

has()

Returns true if the command exists, false otherwise.

public has(string $name) : bool
Parameters
$name : string
Return values
bool

isAutoExitEnabled()

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

public isAutoExitEnabled() : bool
Return values
bool

register()

Registers a new command.

public register(string $name) : Command
Parameters
$name : string
Return values
Command

reset()

public reset() : mixed
Return values
mixed

run()

Runs the current application.

public run([InputInterface|null $input = null ][, OutputInterface|null $output = null ]) : int
Parameters
$input : InputInterface|null = null
$output : OutputInterface|null = null
Tags
throws
Exception

When running fails. Bypass this when .

Return values
int

0 if everything went fine, or an error code

setAutoExit()

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

public setAutoExit(bool $boolean) : mixed
Parameters
$boolean : bool
Return values
mixed

setCatchExceptions()

Sets whether to catch exceptions or not during commands execution.

public setCatchExceptions(bool $boolean) : mixed
Parameters
$boolean : bool
Return values
mixed

setDefaultCommand()

Sets the default Command name.

public setDefaultCommand(string $commandName[, bool $isSingleCommand = false ]) : $this
Parameters
$commandName : string
$isSingleCommand : bool = false
Return values
$this

setName()

Sets the application name.

public setName(string $name) : mixed
Parameters
$name : string
Return values
mixed

setSignalsToDispatchEvent()

public setSignalsToDispatchEvent(int ...$signalsToDispatchEvent) : mixed
Parameters
$signalsToDispatchEvent : int
Return values
mixed

setVersion()

Sets the application version.

public setVersion(string $version) : mixed
Parameters
$version : string
Return values
mixed

getDefaultCommands()

Gets the default commands that should always be available.

protected getDefaultCommands() : array<string|int, Command>
Return values
array<string|int, Command>

getDefaultHelperSet()

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

protected getDefaultHelperSet() : HelperSet
Return values
HelperSet

registerCommands()

protected registerCommands() : mixed
Return values
mixed

extractAllNamespaces()

Returns all namespaces of the command name.

private extractAllNamespaces(string $name) : array<string|int, string>
Parameters
$name : string
Return values
array<string|int, string>

findAlternatives()

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

private findAlternatives(string $name, iteratable<string|int, mixed> $collection) : array<string|int, string>
Parameters
$name : string
$collection : iteratable<string|int, mixed>
Return values
array<string|int, string>

getAbbreviationSuggestions()

Returns abbreviated suggestions in string format.

private getAbbreviationSuggestions(array<string|int, mixed> $abbrevs) : string
Parameters
$abbrevs : array<string|int, mixed>
Return values
string

init()

private init() : mixed
Return values
mixed

splitStringByWidth()

private splitStringByWidth(string $string, int $width) : array<string|int, mixed>
Parameters
$string : string
$width : int
Return values
array<string|int, mixed>

Search results