Application
class Application
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();
Methods
No description
Get the helper set associated with the command.
Gets the InputDefinition related to this Application.
Gets the help message.
Gets whether to catch exceptions or not during commands execution.
Sets whether to catch exceptions or not during commands execution.
Gets whether to automatically exit after a command execution or not.
Sets whether to automatically exit after a command execution or not.
Gets the name of the application.
Sets the application name.
Gets the application version.
Sets the application version.
Returns the long version of the application.
Adds an array of command objects.
Returns true if the command exists, false otherwise.
Returns an array of all unique namespaces used by currently registered commands.
Finds a registered namespace by a name or an abbreviation.
Gets the commands (registered in the given namespace if provided).
Returns an array of possible abbreviations given a set of names.
Configures the input and output instances based on the user arguments and options.
Runs the current command.
Gets the default input definition.
Gets the default commands that should always be available.
Gets the default helper set with the helpers that should always be available.
Returns the namespace part of the command name.
Sets the default Command name.
No description
Details
setCatchExceptions(bool $boolean)
Sets whether to catch exceptions or not during commands execution.
addCommands(array $commands)
Adds an array of command objects.
If a Command is not enabled it will not be added.
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.
string[]
getNamespaces()
Returns an array of all unique namespaces used by currently registered commands.
It does not return the global namespace which always exists.
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.
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.
static array
getAbbreviations(array $names)
Returns an array of possible abbreviations given a set of names.
protected
configureIO(InputInterface $input, OutputInterface $output)
Configures the input and output instances based on the user arguments and options.
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.
protected HelperSet
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.
This method is not part of public API and should not be used directly.
Application
setDefaultCommand(string $commandName, bool $isSingleCommand = false)
Sets the default Command name.