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->addCommand(new SimpleCommand()); $app->run(); - author Fabien Potencier
| Methods |
| public __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN') |
public add(Symfony
|
| public addCommand(Symfony 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. |
| public addCommands(array $commands) : void Adds an array of command objects. If a Command is not enabled it will not be added.
|
| public all(?string $namespace = NULL) : array Gets the commands (registered in the given namespace if provided). The array keys are the full names and the values the command instances.
|
| public areExceptionsCaught() : bool Gets whether to catch exceptions or not during commands execution. |
| public complete(Symfony Adds suggestions to $suggestions for the current completion input (e.g. option or argument). |
| public doRun(Symfony Runs the current application.
|
| public extractNamespace(string $name, ?int $limit = NULL) : string Returns the namespace part of the command name. This method is not part of public API and should not be used directly. |
| public find(string $name) : Symfony 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.
|
| public findNamespace(string $namespace) : string Finds a registered namespace by a name or an abbreviation.
|
| public get(string $name) : Symfony Returns a registered command by name or alias.
|
| public static getAbbreviations(array $names) : array Returns an array of possible abbreviations given a set of names.
|
| public getAlarmInterval() : ?int Gets the interval in seconds on which a SIGALRM signal is dispatched. |
| public getDefinition() : Symfony Gets the InputDefinition related to this Application. |
| public getHelp() : string Gets the help message. |
| public getHelperSet() : Symfony Get the helper set associated with the command. |
| public getLongVersion() : string Returns the long version of the application. |
| public getName() : string Gets the name of the application. |
| public getNamespaces() : array Returns an array of all unique namespaces used by currently registered commands. It does not return the global namespace which always exists.
|
| public getSignalRegistry() : Symfony |
| public getVersion() : string Gets the application version. |
| public has(string $name) : bool Returns true if the command exists, false otherwise. |
| public isAutoExitEnabled() : bool Gets whether to automatically exit after a command execution or not. |
public isSingleCommand() : bool
|
| public register(string $name) : Symfony Registers a new command. |
| public renderThrowable(Throwable $e, Symfony |
| public reset() : void |
| public run(?Symfony Runs the current application.
|
| public setAlarmInterval(?int $seconds) : void Sets the interval to schedule a SIGALRM signal in seconds. |
| public setAutoExit(bool $boolean) : void Sets whether to automatically exit after a command execution or not. |
| public setCatchErrors(bool $catchErrors = true) : void Sets whether to catch errors or not during commands execution. |
| public setCatchExceptions(bool $boolean) : void Sets whether to catch exceptions or not during commands execution. |
| public setCommandLoader(Symfony |
| public setDefaultCommand(string $commandName, bool $isSingleCommand = false) : static Sets the default Command name.
|
| public setDefinition(Symfony |
public setDispatcher(Symfony\Contracts\EventDispatcher\EventDispatcherInterface $dispatcher) : void
|
| public setHelperSet(Symfony |
| public setName(string $name) : void Sets the application name. |
| public setSignalsToDispatchEvent(int $signalsToDispatchEvent) : void |
| public setVersion(string $version) : void Sets the application version. |
| Methods |
| protected configureIO(Symfony Configures the input and output instances based on the user arguments and options. |
| protected doRenderThrowable(Throwable $e, Symfony |
| protected doRunCommand(Symfony 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 getCommandName(Symfony Gets the name of the command based on input. |
| protected getDefaultCommands() : array Gets the default commands that should always be available.
|
| protected getDefaultHelperSet() : Symfony Gets the default helper set with the helpers that should always be available. |
| protected getDefaultInputDefinition() : Symfony Gets the default input definition. |
| Properties |
| private ?int $alarmInterval = NULL |
| private bool $autoExit = true |
| private bool $catchErrors = false |
| private bool $catchExceptions = true |
| private ?Symfony |
| private array $commands = [] |
| private string $defaultCommand |
| private Symfony |
| private ?Symfony\Contracts\EventDispatcher\EventDispatcherInterface $dispatcher = NULL |
| private Symfony |
| private bool $initialized = false |
| private string $name |
| private ?Symfony |
| private ?Symfony |
| private array $signalsToDispatchEvent = [] |
| private bool $singleCommand = false |
| private Symfony |
| private string $version |
| private bool $wantHelps = false |
| Methods |
| private extractAllNamespaces(string $name) : array Returns all namespaces of the command name.
|
| private findAlternatives(string $name, iterable $collection) : array Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs.
|
| private getAbbreviationSuggestions(array $abbrevs) : string Returns abbreviated suggestions in string format. |
| private init() : void |
| private scheduleAlarm() : void |
| private splitStringByWidth(string $string, int $width) : array |
| Methods |
| public static getAbbreviations(array $names) : array Returns an array of possible abbreviations given a set of names.
|