class Application extends Application

Methods

__construct(KernelInterface $kernel)

No description

setDispatcher(EventDispatcherInterface $dispatcher)

No description

setCommandLoader(CommandLoaderInterface $commandLoader)

No description

int
run(InputInterface $input = null, OutputInterface $output = null)

Runs the current application.

int
doRun(InputInterface $input, OutputInterface $output)

Runs the current application.

setHelperSet(HelperSet $helperSet)

No description

getHelperSet()

Get the helper set associated with the command.

setDefinition(InputDefinition $definition)

No description

getDefinition()

Gets the InputDefinition related to this Application.

string
getHelp()

Gets the help message.

bool
areExceptionsCaught()

Gets whether to catch exceptions or not during commands execution.

setCatchExceptions(bool $boolean)

Sets whether to catch exceptions or not during commands execution.

bool
isAutoExitEnabled()

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

setAutoExit(bool $boolean)

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

string
getName()

Gets the name of the application.

setName(string $name)

Sets the application name.

string
getVersion()

Gets the application version.

setVersion(string $version)

Sets the application version.

string
getLongVersion()

Returns the long version of the application.

register(string $name)

Registers a new command.

addCommands(array $commands)

Adds an array of command objects.

Command|null
add(Command $command)

Adds a command object.

get(string $name)

Returns a registered command by name or alias.

bool
has(string $name)

Returns true if the command exists, false otherwise.

string[]
getNamespaces()

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

string
findNamespace(string $namespace)

Finds a registered namespace by a name or an abbreviation.

find(string $name)

Finds a command by name or alias.

all(string $namespace = null)

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

static array
getAbbreviations(array $names)

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

renderException(Exception $e, OutputInterface $output)

Renders a caught exception.

doRenderException(Exception $e, OutputInterface $output)

No description

int|null
getTerminalWidth() deprecated

Tries to figure out the terminal width in which this application runs.

int|null
getTerminalHeight() deprecated

Tries to figure out the terminal height in which this application runs.

array
getTerminalDimensions() deprecated

Tries to figure out the terminal dimensions based on the current environment.

$this
setTerminalDimensions(int $width, int $height) deprecated

Sets terminal dimensions.

configureIO(InputInterface $input, OutputInterface $output)

Configures the input and output instances based on the user arguments and options.

int
doRunCommand(Command $command, InputInterface $input, OutputInterface $output)

Runs the current command.

string
getCommandName(InputInterface $input)

Gets the name of the command based on input.

getDefaultInputDefinition()

Gets the default input definition.

getDefaultCommands()

Gets the default commands that should always be available.

getDefaultHelperSet()

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

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

Returns the namespace part of the command name.

setDefaultCommand(string $commandName, bool $isSingleCommand = false)

Sets the default Command name.

isSingleCommand()

No description

getKernel()

Gets the Kernel associated with this Console.

registerCommands()

No description

Details

at line 36
__construct(KernelInterface $kernel)

Parameters

KernelInterface $kernel

in Application at line 92
setDispatcher(EventDispatcherInterface $dispatcher)

Parameters

EventDispatcherInterface $dispatcher

in Application at line 97
setCommandLoader(CommandLoaderInterface $commandLoader)

Parameters

CommandLoaderInterface $commandLoader

in Application at line 109
int run(InputInterface $input = null, OutputInterface $output = null)

Runs the current application.

Parameters

InputInterface $input
OutputInterface $output

Return Value

int 0 if everything went fine, or an error code

Exceptions

Exception When running fails. Bypass this when {@link setCatchExceptions()}.

at line 62
int doRun(InputInterface $input, OutputInterface $output)

Runs the current application.

Parameters

InputInterface $input
OutputInterface $output

Return Value

int 0 if everything went fine, or an error code

in Application at line 254
setHelperSet(HelperSet $helperSet)

Parameters

HelperSet $helperSet

in Application at line 264
HelperSet getHelperSet()

Get the helper set associated with the command.

Return Value

HelperSet The HelperSet instance associated with this command

in Application at line 273
setDefinition(InputDefinition $definition)

Parameters

InputDefinition $definition

in Application at line 283
InputDefinition getDefinition()

Gets the InputDefinition related to this Application.

Return Value

InputDefinition The InputDefinition instance

in Application at line 304
string getHelp()

Gets the help message.

Return Value

string A help message

in Application at line 314
bool areExceptionsCaught()

Gets whether to catch exceptions or not during commands execution.

Return Value

bool Whether to catch exceptions or not during commands execution

in Application at line 324
setCatchExceptions(bool $boolean)

Sets whether to catch exceptions or not during commands execution.

Parameters

bool $boolean Whether to catch exceptions or not during commands execution

in Application at line 334
bool isAutoExitEnabled()

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

Return Value

bool Whether to automatically exit after a command execution or not

in Application at line 344
setAutoExit(bool $boolean)

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

Parameters

bool $boolean Whether to automatically exit after a command execution or not

in Application at line 354
string getName()

Gets the name of the application.

Return Value

string The application name

in Application at line 364
setName(string $name)

Sets the application name.

Parameters

string $name The application name

in Application at line 374
string getVersion()

Gets the application version.

Return Value

string The application version

in Application at line 384
setVersion(string $version)

Sets the application version.

Parameters

string $version The application version

at line 128
string getLongVersion()

Returns the long version of the application.

Return Value

string The long application version

in Application at line 414
Command register(string $name)

Registers a new command.

Parameters

string $name The command name

Return Value

Command The newly created command

in Application at line 426
addCommands(array $commands)

Adds an array of command objects.

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

Parameters

array $commands An array of commands

at line 133
Command|null add(Command $command)

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

Command $command

Return Value

Command|null The registered command if enabled or null

at line 102
Command get(string $name)

Returns a registered command by name or alias.

Parameters

string $name The command name or alias

Return Value

Command A Command object

Exceptions

CommandNotFoundException When given command name does not exist

in Application at line 508
bool has(string $name)

Returns true if the command exists, false otherwise.

Parameters

string $name The command name or alias

Return Value

bool true if the command exists, false otherwise

in Application at line 522
string[] getNamespaces()

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

It does not return the global namespace which always exists.

Return Value

string[] An array of namespaces

in Application at line 545
string findNamespace(string $namespace)

Finds a registered namespace by a name or an abbreviation.

Parameters

string $namespace A namespace or abbreviation to search for

Return Value

string A registered namespace

Exceptions

CommandNotFoundException When namespace is incorrect or ambiguous

at line 92
Command find(string $name)

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

Return Value

Command A Command instance

Exceptions

CommandNotFoundException When command name is incorrect or ambiguous

at line 118
Command[] all(string $namespace = null)

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

Return Value

Command[] An array of Command instances

in Application at line 709
static array getAbbreviations(array $names)

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

Parameters

array $names An array of names

Return Value

array An array of abbreviations

in Application at line 725
renderException(Exception $e, OutputInterface $output)

Renders a caught exception.

Parameters

Exception $e
OutputInterface $output

in Application at line 737
protected doRenderException(Exception $e, OutputInterface $output)

Parameters

Exception $e
OutputInterface $output

in Application at line 815
protected int|null getTerminalWidth() deprecated

deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.

Tries to figure out the terminal width in which this application runs.

Return Value

int|null

in Application at line 829
protected int|null getTerminalHeight() deprecated

deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.

Tries to figure out the terminal height in which this application runs.

Return Value

int|null

in Application at line 843
array getTerminalDimensions() deprecated

deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.

Tries to figure out the terminal dimensions based on the current environment.

Return Value

array Array containing width and height

in Application at line 862
$this setTerminalDimensions(int $width, int $height) deprecated

deprecated since version 3.2, to be removed in 4.0. Set the COLUMNS and LINES env vars instead.

Sets terminal dimensions.

Can be useful to force terminal dimensions for functional tests.

Parameters

int $width The width
int $height The height

Return Value

$this

in Application at line 875
protected configureIO(InputInterface $input, OutputInterface $output)

Configures the input and output instances based on the user arguments and options.

Parameters

InputInterface $input
OutputInterface $output

at line 80
protected int doRunCommand(Command $command, InputInterface $input, OutputInterface $output)

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

Command $command
InputInterface $input
OutputInterface $output

Return Value

int 0 if everything went fine, or an error code

in Application at line 1012
protected string getCommandName(InputInterface $input)

Gets the name of the command based on input.

Parameters

InputInterface $input

Return Value

string The command name

in Application at line 1022
protected InputDefinition getDefaultInputDefinition()

Gets the default input definition.

Return Value

InputDefinition An InputDefinition instance

in Application at line 1042
protected Command[] getDefaultCommands()

Gets the default commands that should always be available.

Return Value

Command[] An array of default Command instances

in Application at line 1052
protected HelperSet getDefaultHelperSet()

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

Return Value

HelperSet A HelperSet instance

in Application at line 1084
string extractNamespace(string $name, string $limit = null)

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

Return Value

string The namespace of the command

in Application at line 1151
Application setDefaultCommand(string $commandName, bool $isSingleCommand = false)

Sets the default Command name.

Parameters

string $commandName The Command name
bool $isSingleCommand Set to true if there is only one command in this application

Return Value

Application

in Application at line 1168
isSingleCommand()

at line 52
KernelInterface getKernel()

Gets the Kernel associated with this Console.

Return Value

KernelInterface A KernelInterface instance

at line 140
protected registerCommands()