Application extends from Application by providing functionalities that are
specific to console requests. In particular, it deals with console requests
through a command-based approach:
- A console application consists of one or several possible user commands;
- Each user command is implemented as a class extending Controller;
- User specifies which command to run on the command line;
- The command processes the user request with the specified parameters.
The command classes should be under the namespace specified by [[controllerNamespace]].
Their naming should follow the same naming convention as controllers. For example, the help command
is implemented using the HelpController class.
To run the console application, enter the following on the command line:
~~~
yii [--param1=value1 --param2 ...]
~~~
where refers to a controller route in the form of ModuleID/ControllerID/ActionID
(e.g. sitemap/create), and param1, param2 refers to a set of named parameters that
will be used to initialize the controller action (e.g. --since=0 specifies a since parameter
whose value is 0 and a corresponding $since parameter is passed to the action method).
A help command is provided by default, which lists available commands and shows their usage.
To use this command, simply type:
~~~
yii help
~~~