UnknownCommandException
API reference › yii › console › UnknownCommandException
UnknownCommandException represents an exception caused by incorrect usage of a console command.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$command | string | The name of the command that could not be recognized. Default: null. | UnknownCommandException |
$application protected | Application | Default: null. | UnknownCommandException |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Construct the exception. | UnknownCommandException |
getName() | UnknownCommandException | |
getSuggestedAlternatives() | Suggest alternative commands for $command based on string similarity. | UnknownCommandException |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string $route, yii\console\Application $application, int $code = 0, Throwable|null $previous = null)Construct the exception.
Parameters
| Parameter | Type | Description |
|---|---|---|
$route | string | The route of the command that could not be found. |
$application | Application | The console application instance involved. |
$code | int | The Exception code. |
$previous | Throwable| | The previous exception used for the exception chaining. |
getName()
Section titled “getName() ”public function getName(): stringReturns
string: The user-friendly name of this exception
getSuggestedAlternatives()
Section titled “getSuggestedAlternatives() ”public function getSuggestedAlternatives(): arraySuggest alternative commands for $command based on string similarity.
Alternatives are searched using the following steps:
- suggest alternatives that begin with
$command - find typos by calculating the Levenshtein distance between the unknown command and all available commands. The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform str1 into str2.
Returns
array: A list of suggested alternatives sorted by similarity.
See also