Application
    
            
            in package
            
        
    
            
            implements
                            ResetInterface                    
    
    
An Application is the container for a collection of commands.
It is the main entry point of a Console application.
This class is optimized for a standard CLI environment.
Usage:
$app = new Application('myapp', '1.0 (stable)');
$app->add(new SimpleCommand());
$app->run();
Tags
Table of Contents
Interfaces
- ResetInterface
 - Provides a way to reset an object to its initial state.
 
Methods
- __construct() : mixed
 - add() : Command|null
 - Adds a command object.
 - addCommands() : void
 - 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.
 - getAlarmInterval() : int|null
 - Gets the interval in seconds on which a SIGALRM signal is dispatched.
 - 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.
 - 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() : void
 - run() : int
 - Runs the current application.
 - setAlarmInterval() : void
 - Sets the interval to schedule a SIGALRM signal in seconds.
 - setAutoExit() : void
 - Sets whether to automatically exit after a command execution or not.
 - setCatchErrors() : void
 - Sets whether to catch errors or not during commands execution.
 - setCatchExceptions() : void
 - Sets whether to catch exceptions or not during commands execution.
 - setCommandLoader() : void
 - setDefaultCommand() : $this
 - Sets the default Command name.
 - setDefinition() : void
 - setDispatcher() : void
 - setHelperSet() : void
 - setName() : void
 - Sets the application name.
 - setSignalsToDispatchEvent() : void
 - setVersion() : void
 - Sets the application version.
 - configureIO() : void
 - 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.
 
Methods
__construct()
    public
                    __construct([string $name = 'UNKNOWN' ][, string $version = 'UNKNOWN' ]) : mixed
    Parameters
- $name : string = 'UNKNOWN'
 - $version : string = 'UNKNOWN'
 
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|nulladdCommands()
Adds an array of command objects.
    public
                    addCommands(array<string|int, Command> $commands) : void
    If a Command is not enabled it will not be added.
Parameters
- $commands : array<string|int, Command>
 - 
                    
An array of commands
 
all()
Gets the commands (registered in the given namespace if provided).
    public
                    all([string|null $namespace = null ]) : array<string|int, Command>
    The array keys are the full names and the values the command instances.
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
boolcomplete()
Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
    public
                    complete(CompletionInput $input, CompletionSuggestions $suggestions) : void
    Parameters
- $input : CompletionInput
 - $suggestions : CompletionSuggestions
 
doRun()
Runs the current application.
    public
                    doRun(InputInterface $input, OutputInterface $output) : int
    Parameters
- $input : InputInterface
 - $output : OutputInterface
 
Return values
int —0 if everything went fine, or an error code
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
stringfind()
Finds a command by name or alias.
    public
                    find(string $name) : Command
    Contrary to get, this command tries to find the best match if you give it an abbreviation of a name or alias.
Parameters
- $name : string
 
Tags
Return values
CommandfindNamespace()
Finds a registered namespace by a name or an abbreviation.
    public
                    findNamespace(string $namespace) : string
    Parameters
- $namespace : string
 
Tags
Return values
stringget()
Returns a registered command by name or alias.
    public
                    get(string $name) : Command
    Parameters
- $name : string
 
Tags
Return values
CommandgetAbbreviations()
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>>getAlarmInterval()
Gets the interval in seconds on which a SIGALRM signal is dispatched.
    public
                    getAlarmInterval() : int|null
    Return values
int|nullgetDefinition()
Gets the InputDefinition related to this Application.
    public
                    getDefinition() : InputDefinition
    Return values
InputDefinitiongetHelp()
Gets the help message.
    public
                    getHelp() : string
    Return values
stringgetHelperSet()
Get the helper set associated with the command.
    public
                    getHelperSet() : HelperSet
    Return values
HelperSetgetLongVersion()
Returns the long version of the application.
    public
                    getLongVersion() : string
    Return values
stringgetName()
Gets the name of the application.
    public
                    getName() : string
    Return values
stringgetNamespaces()
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>getSignalRegistry()
    public
                    getSignalRegistry() : SignalRegistry
    Return values
SignalRegistrygetVersion()
Gets the application version.
    public
                    getVersion() : string
    Return values
stringhas()
Returns true if the command exists, false otherwise.
    public
                    has(string $name) : bool
    Parameters
- $name : string
 
Return values
boolisAutoExitEnabled()
Gets whether to automatically exit after a command execution or not.
    public
                    isAutoExitEnabled() : bool
    Return values
boolregister()
Registers a new command.
    public
                    register(string $name) : Command
    Parameters
- $name : string
 
Return values
CommandrenderThrowable()
    public
                    renderThrowable(Throwable $e, OutputInterface $output) : void
    Parameters
- $e : Throwable
 - $output : OutputInterface
 
reset()
    public
                    reset() : void
    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
Return values
int —0 if everything went fine, or an error code
setAlarmInterval()
Sets the interval to schedule a SIGALRM signal in seconds.
    public
                    setAlarmInterval(int|null $seconds) : void
    Parameters
- $seconds : int|null
 
setAutoExit()
Sets whether to automatically exit after a command execution or not.
    public
                    setAutoExit(bool $boolean) : void
    Parameters
- $boolean : bool
 
setCatchErrors()
Sets whether to catch errors or not during commands execution.
    public
                    setCatchErrors([bool $catchErrors = true ]) : void
    Parameters
- $catchErrors : bool = true
 
setCatchExceptions()
Sets whether to catch exceptions or not during commands execution.
    public
                    setCatchExceptions(bool $boolean) : void
    Parameters
- $boolean : bool
 
setCommandLoader()
    public
                    setCommandLoader(CommandLoaderInterface $commandLoader) : void
    Parameters
- $commandLoader : CommandLoaderInterface
 
setDefaultCommand()
Sets the default Command name.
    public
                    setDefaultCommand(string $commandName[, bool $isSingleCommand = false ]) : $this
    Parameters
- $commandName : string
 - $isSingleCommand : bool = false
 
Return values
$thissetDefinition()
    public
                    setDefinition(InputDefinition $definition) : void
    Parameters
- $definition : InputDefinition
 
setDispatcher()
    public
                    setDispatcher(EventDispatcherInterface $dispatcher) : void
    Parameters
- $dispatcher : EventDispatcherInterface
 
Tags
setHelperSet()
    public
                    setHelperSet(HelperSet $helperSet) : void
    Parameters
- $helperSet : HelperSet
 
setName()
Sets the application name.
    public
                    setName(string $name) : void
    Parameters
- $name : string
 
setSignalsToDispatchEvent()
    public
                    setSignalsToDispatchEvent(int ...$signalsToDispatchEvent) : void
    Parameters
- $signalsToDispatchEvent : int
 
setVersion()
Sets the application version.
    public
                    setVersion(string $version) : void
    Parameters
- $version : string
 
configureIO()
Configures the input and output instances based on the user arguments and options.
    protected
                    configureIO(InputInterface $input, OutputInterface $output) : void
    Parameters
- $input : InputInterface
 - $output : OutputInterface
 
doRenderThrowable()
    protected
                    doRenderThrowable(Throwable $e, OutputInterface $output) : void
    Parameters
- $e : Throwable
 - $output : OutputInterface
 
doRunCommand()
Runs the current command.
    protected
                    doRunCommand(Command $command, InputInterface $input, OutputInterface $output) : int
    If an event dispatcher has been attached to the application, events are also dispatched during the life-cycle of the command.
Parameters
- $command : Command
 - $input : InputInterface
 - $output : OutputInterface
 
Return values
int —0 if everything went fine, or an error code
getCommandName()
Gets the name of the command based on input.
    protected
                    getCommandName(InputInterface $input) : string|null
    Parameters
- $input : InputInterface
 
Return values
string|nullgetDefaultCommands()
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
HelperSetgetDefaultInputDefinition()
Gets the default input definition.
    protected
                    getDefaultInputDefinition() : InputDefinition