HelpController ​
- Type
- Class
- Namespace
- craft\console\controllers
- Inherits
- craft\console\controllers\HelpController » yii\console\controllers\HelpController » yii\console\Controller » yii\base\Controller » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable, yii\base\ViewContextInterface
- Since
- 3.7.56
Provides help information about console commands.
This command displays the available command list in the application or the detailed instructions about using a specific command.
This command can be used as follows on command line:
yii help [command name]
In the above, if the command name is not provided, all available commands will be displayed.
Public Properties ​
Property | Description |
---|---|
action | yii\base\Action, null – The action that is currently being executed. |
asJson | boolean – Should the commands help be returned in JSON format? |
behaviors | yii\base\Behavior – List of behaviors attached to this component. |
color | boolean, null – Whether to enable ANSI color in the output. |
commands | array – All available command names. |
defaultAction | string – The ID of the action that is used when the action ID is not specified in the request. |
help | boolean – Whether to display help information about current command. |
helpSummary | string |
id | string – The ID of this controller. |
interactive | boolean – Whether to run the command interactively. |
layout | string, null, false – The name of the layout to be applied to this controller's views. |
module | yii\base\Module – The module that this controller belongs to. |
modules | yii\base\Module – All ancestor modules that this controller is located within. |
passedOptionValues | array – The properties corresponding to the passed options. |
passedOptions | array – The names of the options passed during execution. |
request | yii\base\Request, array, string – The request. |
response | yii\base\Response, array, string – The response. |
route | string – The route (module ID, controller ID and action ID) of the current request. |
silentExitOnException | boolean, null – If true - script finish with ExitCode::OK in case of exception. |
uniqueId | string – The controller ID that is prefixed with the module ID (if any). |
view | yii\base\View, yii\web\View – The view object that can be used to render views or view files. |
viewPath | string – The directory containing the view files for this controller. |
asJson
​
- Type
- boolean
- Default value
false
Should the commands help be returned in JSON format?
Public Methods ​
Method | Description |
---|---|
__call() | Calls the named method which is not a class method. |
__clone() | This method is called after the object is created by cloning an existing one. |
__construct() | |
__get() | Returns the value of a component property. |
__isset() | Checks if a property is set, i.e. defined and not null. |
__set() | Sets the value of a component property. |
__unset() | Sets a component property to be null. |
actionIndex() | Displays available commands or the detailed information about a particular command. |
actionList() | List all available controllers and actions in machine readable format. |
actionListActionOptions() | List all available options for the $action in machine readable format. |
actionUsage() | Displays usage information for $action. |
actions() | Declares external actions for the controller. |
afterAction() | This method is invoked right after an action is executed. |
ansiFormat() | Formats a string with ANSI codes. |
attachBehavior() | Attaches a behavior to this component. |
attachBehaviors() | Attaches a list of behaviors to the component. |
beforeAction() | This method is invoked right before an action is executed. |
behaviors() | Returns a list of behaviors that this component should behave as. |
bindActionParams() | Binds the parameters to the action. |
canGetProperty() | Returns a value indicating whether a property can be read. |
canSetProperty() | Returns a value indicating whether a property can be set. |
className() | Returns the fully qualified name of this class. |
confirm() | Asks user to confirm by typing y or n. |
createAction() | Creates an action based on the given action ID. |
detachBehavior() | Detaches a behavior from the component. |
detachBehaviors() | Detaches all behaviors from the component. |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. |
findLayoutFile() | Finds the applicable layout file. |
getActionArgsHelp() | Returns the help information for the anonymous arguments for the action. |
getActionHelp() | Returns the detailed help information for the specified action. |
getActionHelpSummary() | Returns a one-line short summary describing the specified action. |
getActionOptionsHelp() | Returns the help information for the options for the action. |
getActions() | Returns all available actions of the specified controller. |
getBehavior() | Returns the named behavior object. |
getBehaviors() | Returns all behaviors attached to this component. |
getCommands() | Returns all available command names. |
getHelp() | Returns help information for this controller. |
getHelpSummary() | Returns one-line short summary describing this controller. |
getModules() | Returns all ancestor modules of this controller. |
getOptionValues() | Returns properties corresponding to the options for the action id Child classes may override this method to specify possible properties. |
getPassedOptionValues() | Returns the properties corresponding to the passed options. |
getPassedOptions() | Returns the names of valid options passed during execution. |
getRoute() | Returns the route of the current request. |
getUniqueId() | Returns the unique ID of the controller. |
getView() | Returns the view object that can be used to render views or view files. |
getViewPath() | Returns the directory containing view files for this controller. |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. |
hasMethod() | Returns a value indicating whether a method is defined. |
hasProperty() | Returns a value indicating whether a property is defined for this component. |
init() | Initializes the object. |
isColorEnabled() | Returns a value indicating whether ANSI color is enabled. |
off() | Detaches an existing event handler from this component. |
on() | Attaches an event handler to an event. |
optionAliases() | Returns option alias names. |
options() | Returns the names of valid options for the action (id) An option requires the existence of a public member variable whose name is the option name. |
prompt() | Prompts the user for input and validates it. |
render() | Renders a view and applies layout if available. |
renderContent() | Renders a static string by applying a layout. |
renderFile() | Renders a view file. |
renderPartial() | Renders a view without applying layout. |
run() | Runs a request specified in terms of a route. |
runAction() | Runs an action with the specified action ID and parameters. |
select() | Gives the user an option to choose from. Giving '?' as an input will show a list of options to choose from and their explanations. |
setView() | Sets the view object to be used by this controller. |
setViewPath() | Sets the directory that contains the view files. |
stderr() | Prints a string to STDERR. |
stdout() | Prints a string to STDOUT. |
trigger() | Triggers an event. |
actionIndex()
​
Displays available commands or the detailed information about a particular command.
Arguments ​
$command
(string) – The name of the command to show help about. If not provided, all available commands will be displayed.
Returns ​
integer – The exit status
Throws ​
- yii\console\Exception
if the command for help is unknown
optionAliases()
​
Returns option alias names.
Child classes may override this method to specify alias options.
Returns ​
array – The options alias names valid for the action where the keys is alias name for option and value is option name.
options()
​
Returns the names of valid options for the action (id) An option requires the existence of a public member variable whose name is the option name.
Child classes may override this method to specify possible options.
Note that the values setting via options are not available until beforeAction() is being called.
Arguments ​
$actionID
(string) – The action id of the current request
Returns ​
string[] – The names of the options valid for the action
Protected Methods ​
Method | Description |
---|---|
allCommandsInfo() | Return an array of information for every CLI command |
bindInjectedParams() | Fills parameters based on types and names in action method signature. |
commandInfo() | Return an array of information on the passed in CLI $command |
commentCleanup() | Cleans up a comment. |
formatOptionAliases() | |
formatOptionHelp() | Generates a well-formed string for an argument or option. |
getActionMethodReflection() | |
getCommandDescriptions() | Returns an array of commands an their descriptions. |
getCommandHelp() | Displays the overall information of the command. |
getDefaultHelp() | Displays all available commands. |
getDefaultHelpHeader() | Return a default help header. |
getModuleCommands() | Returns available commands of a specified module. |
getScriptName() | |
getSubCommandHelp() | Displays the detailed information of a command action. |
parseDocCommentDetail() | Returns full description from the docblock. |
parseDocCommentSummary() | Returns the first line of docblock. |
parseDocCommentTags() | Parses the comment block into tags. |
unformattedActionHelp() | Returns full description from the docblock without any kind of ANSI terminal formatting |
validateControllerClass() | Validates if the given class is a valid console controller class. |
allCommandsInfo()
​
Return an array of information for every CLI command
Returns ​
Throws ​
commandInfo()
​
Return an array of information on the passed in CLI $command
Arguments ​
$command
(string)
Returns ​
Throws ​
commentCleanup()
​
Cleans up a comment.
Arguments ​
$comment
(string)
Returns ​
unformattedActionHelp()
​
Returns full description from the docblock without any kind of ANSI terminal formatting
See also yii\console\Controller::getActionHelp()View source
Arguments ​
$reflection
(ReflectionFunctionAbstract)
Returns ​
Constants ​
Constant | Description |
---|---|
EXIT_CODE_ERROR | |
EXIT_CODE_NORMAL |