function Application::get
Returns a registered command by name or alias.
Throws
CommandNotFoundException When given command name does not exist
2 calls to Application::get()
- Application::all in vendor/
symfony/ console/ Application.php - Gets the commands (registered in the given namespace if provided).
- Application::find in vendor/
symfony/ console/ Application.php - Finds a command by name or alias.
File
-
vendor/
symfony/ console/ Application.php, line 574
Class
- Application
- An Application is the container for a collection of commands.
Namespace
Symfony\Component\ConsoleCode
public function get(string $name) : Command {
$this->init();
if (!$this->has($name)) {
throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name));
}
// When the command has a different name than the one used at the command loader level
if (!isset($this->commands[$name])) {
throw new CommandNotFoundException(\sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name));
}
$command = $this->commands[$name];
if ($this->wantHelps) {
$this->wantHelps = false;
$helpCommand = $this->get('help');
$helpCommand->setCommand($command);
return $helpCommand;
}
return $command;
}