$commands
$commands :
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();
setCommandLoader(\Symfony\Component\Console\CommandLoader\CommandLoaderInterface $commandLoader)
\Symfony\Component\Console\CommandLoader\CommandLoaderInterface | $commandLoader |
run(\Symfony\Component\Console\Input\InputInterface $input = null, \Symfony\Component\Console\Output\OutputInterface $output = null) : integer
Runs the current application.
\Symfony\Component\Console\Input\InputInterface | $input | |
\Symfony\Component\Console\Output\OutputInterface | $output |
When running fails. Bypass this when {@link setCatchExceptions()}.
0 if everything went fine, or an error code
doRun(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) : integer
Runs the current application.
\Symfony\Component\Console\Input\InputInterface | $input | |
\Symfony\Component\Console\Output\OutputInterface | $output |
0 if everything went fine, or an error code
setHelperSet(\Symfony\Component\Console\Helper\HelperSet $helperSet)
\Symfony\Component\Console\Helper\HelperSet | $helperSet |
getHelperSet() : \Symfony\Component\Console\Helper\HelperSet
Get the helper set associated with the command.
The HelperSet instance associated with this command
setDefinition(\Symfony\Component\Console\Input\InputDefinition $definition)
\Symfony\Component\Console\Input\InputDefinition | $definition |
getDefinition() : \Symfony\Component\Console\Input\InputDefinition
Gets the InputDefinition related to this Application.
The InputDefinition instance
register(string $name) : \Symfony\Component\Console\Command\Command
Registers a new command.
string | $name | The command name |
The newly created command
addCommands(array<mixed,\Symfony\Component\Console\Command\Command> $commands)
Adds an array of command objects.
If a Command is not enabled it will not be added.
array<mixed,\Symfony\Component\Console\Command\Command> | $commands | An array of commands |
add(\Symfony\Component\Console\Command\Command $command) : \Symfony\Component\Console\Command\Command|null
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.
\Symfony\Component\Console\Command\Command | $command |
The registered command if enabled or null
get(string $name) : \Symfony\Component\Console\Command\Command
Returns a registered command by name or alias.
string | $name | The command name or alias |
When given command name does not exist
A Command object
findNamespace(string $namespace) : string
Finds a registered namespace by a name or an abbreviation.
string | $namespace | A namespace or abbreviation to search for |
When namespace is incorrect or ambiguous
A registered namespace
find(string $name) : \Symfony\Component\Console\Command\Command
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.
string | $name | A command name or a command alias |
When command name is incorrect or ambiguous
A Command instance
all(string $namespace = null) : array<mixed,\Symfony\Component\Console\Command\Command>
Gets the commands (registered in the given namespace if provided).
The array keys are the full names and the values the command instances.
string | $namespace | A namespace name |
An array of Command instances
renderException(\Exception $e, \Symfony\Component\Console\Output\OutputInterface $output)
Renders a caught exception.
\Exception | $e | |
\Symfony\Component\Console\Output\OutputInterface | $output |
extractNamespace(string $name, string $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.
string | $name | The full name of the command |
string | $limit | The maximum number of parts of the namespace |
The namespace of the command
doRenderException(\Exception $e, \Symfony\Component\Console\Output\OutputInterface $output)
\Exception | $e | |
\Symfony\Component\Console\Output\OutputInterface | $output |
configureIO(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
Configures the input and output instances based on the user arguments and options.
\Symfony\Component\Console\Input\InputInterface | $input | |
\Symfony\Component\Console\Output\OutputInterface | $output |
doRunCommand(\Symfony\Component\Console\Command\Command $command, \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) : integer
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.
\Symfony\Component\Console\Command\Command | $command | |
\Symfony\Component\Console\Input\InputInterface | $input | |
\Symfony\Component\Console\Output\OutputInterface | $output |
0 if everything went fine, or an error code
getCommandName(\Symfony\Component\Console\Input\InputInterface $input) : string
Gets the name of the command based on input.
\Symfony\Component\Console\Input\InputInterface | $input |
The command name
getDefaultInputDefinition() : \Symfony\Component\Console\Input\InputDefinition
Overwrites the default input definition.
An InputDefinition instance
getDefaultCommands() : array<mixed,\Symfony\Component\Console\Command\Command>
Gets the default commands that should always be available.
An array of default Command instances
getDefaultHelperSet() : \Symfony\Component\Console\Helper\HelperSet
Gets the default helper set with the helpers that should always be available.
A HelperSet instance
findAlternatives(string $name, \Symfony\Component\Console\iterable $collection) : array<mixed,string>
Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs.
string | $name | The string |
\Symfony\Component\Console\iterable | $collection | The collection |
A sorted array of similar string