Symfony\Component\Console\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();
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
class Application
{
- // members
- private $commands;
- private $wantHelps;
- private $runningCommand;
- private $name;
- private $version;
- private $catchExceptions;
- private $autoExit;
- private $definition;
- private $helperSet;
- private $dispatcher;
- // methods
- public void __construct()
- public void setDispatcher()
- public integer run()
- public integer doRun()
- public void setHelperSet()
- public HelperSet getHelperSet()
- public void setDefinition()
- public InputDefinition getDefinition()
- public string getHelp()
- public void setCatchExceptions()
- public void setAutoExit()
- public string getName()
- public void setName()
- public string getVersion()
- public void setVersion()
- public string getLongVersion()
- public Command register()
- public void addCommands()
- public Command add()
- public Command get()
- public Boolean has()
- public array getNamespaces()
- public string findNamespace()
- public Command find()
- public array all()
- public static array getAbbreviations()
- public string asText()
- public DOMDocument asXml()
- public void renderException()
- protected int|null getTerminalWidth()
- protected int|null getTerminalHeight()
- public array getTerminalDimensions()
- protected void configureIO()
- protected integer doRunCommand()
- protected string getCommandName()
- protected InputDefinition getDefaultInputDefinition()
- protected array getDefaultCommands()
- protected HelperSet getDefaultHelperSet()
- private string getSttyColumns()
- private string getConsoleMode()
- private string getAbbreviationSuggestions()
- public string extractNamespace()
- private array findAlternativeCommands()
- private array findAlternativeNamespace()
- private array findAlternatives()
Hierarchy
Members
private
- $autoExit
- $catchExceptions
- $commands
- $definition
- $dispatcher
- $helperSet
- $name
- $runningCommand
- $version
- $wantHelps
Methods
private
- findAlternativeCommands() — Finds alternative commands of $name
- findAlternativeNamespace() — Finds alternative namespace of $name
- findAlternatives() — Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs
- getAbbreviationSuggestions() — Returns abbreviated suggestions in string format.
- getConsoleMode() — Runs and parses mode CON if it's available, suppressing any error output
- getSttyColumns() — Runs and parses stty -a if it's available, suppressing any error output
protected
- configureIO() — Configures the input and output instances based on the user arguments and options.
- doRunCommand() — Runs the current command.
- getCommandName() — Gets the name of the command based on input.
- getDefaultCommands() — Gets the default commands that should always be available.
- getDefaultHelperSet() — Gets the default helper set with the helpers that should always be available.
- getDefaultInputDefinition() — Gets the default input definition.
- getTerminalHeight() — Tries to figure out the terminal height in which this application runs
- getTerminalWidth() — Tries to figure out the terminal width in which this application runs
public
- __construct() — Constructor.
- add() — Adds a command object.
- addCommands() — Adds an array of command objects.
- all() — Gets the commands (registered in the given namespace if provided).
- asText() — Returns a text representation of the Application.
- asXml() — Returns an XML representation of the Application.
- doRun() — Runs the current application.
- extractNamespace() — Returns the namespace part of the command name.
- find() — Finds a command by name or alias.
- findNamespace() — Finds a registered namespace by a name or an abbreviation.
- get() — Returns a registered command by name or alias.
- getAbbreviations() — Returns an array of possible abbreviations given a set of names.
- getDefinition() — Gets the InputDefinition related to this Application.
- getHelp() — Gets the help message.
- getHelperSet() — Get the helper set associated with the command.
- getLongVersion() — Returns the long version of the application.
- getName() — Gets the name of the application.
- getNamespaces() — Returns an array of all unique namespaces used by currently registered commands.
- getTerminalDimensions() — Tries to figure out the terminal dimensions based on the current environment
- getVersion() — Gets the application version.
- has() — Returns true if the command exists, false otherwise.
- register() — Registers a new command.
- renderException() — Renders a caught exception.
- run() — Runs the current application.
- setAutoExit() — Sets whether to automatically exit after a command execution or not.
- setCatchExceptions() — Sets whether to catch exceptions or not during commands execution.
- setDefinition() — Set an input definition set to be used with this application
- setDispatcher()
- setHelperSet() — Set a helper set to be used with the command.
- setName() — Sets the application name.
- setVersion() — Sets the application version.