PHP Class think\console\Command

显示文件 Open project: top-think/framework Class Usage Examples

Protected Properties

Property Type Description
$input Input
$output Output

Public Methods

Method Description
__construct ( string | null $name = null ) 构造方法
addArgument ( string $name, integer $mode = null, string $description = '', mixed $default = null ) : Command 添加参数
addOption ( string $name, string $shortcut = null, integer $mode = null, string $description = '', mixed $default = null ) : Command 添加选项
addUsage ( string $usage ) 添加用法介绍
getAliases ( ) : array 获取别名
getConsole ( ) : Console 获取控制台
getDefinition ( ) : Definition 获取参数定义
getDescription ( ) : string 获取描述
getHelp ( ) : string 获取帮助信息
getName ( ) : string 获取指令名称
getNativeDefinition ( ) : Definition 获取当前指令的参数定义
getProcessedHelp ( ) : string 描述信息
getSynopsis ( boolean $short = false ) : string 获取简介
getUsages ( ) : array 获取用法介绍
ignoreValidationErrors ( ) 忽略验证错误
isEnabled ( ) : boolean 是否有效
mergeConsoleDefinition ( boolean $mergeArgs = true ) 合并参数定义
run ( Input $input, Output $output ) : integer 执行
setAliases ( string[] $aliases ) : Command 设置别名
setCode ( callable $code ) : Command 设置执行代码
setConsole ( Console $console = null ) 设置控制台
setDefinition ( array | Definition $definition ) : Command 设置参数定义
setDescription ( string $description ) : Command 设置描述
setHelp ( string $help ) : Command 设置帮助信息
setName ( string $name ) : Command 设置指令名称

Protected Methods

Method Description
configure ( ) 配置指令
execute ( Input $input, Output $output ) : null | integer 执行指令
initialize ( Input $input, Output $output ) 初始化
interact ( Input $input, Output $output ) 用户验证

Private Methods

Method Description
validateName ( string $name ) 验证指令名称

Method Details

__construct() public method

构造方法
public __construct ( string | null $name = null )
$name string | null 命令名称,如果没有设置则比如在 configure() 里设置

addArgument() public method

添加参数
public addArgument ( string $name, integer $mode = null, string $description = '', mixed $default = null ) : Command
$name string 名称
$mode integer 类型
$description string 描述
$default mixed 默认值
return Command

addOption() public method

添加选项
public addOption ( string $name, string $shortcut = null, integer $mode = null, string $description = '', mixed $default = null ) : Command
$name string 选项名称
$shortcut string 别名
$mode integer 类型
$description string 描述
$default mixed 默认值
return Command

addUsage() public method

添加用法介绍
public addUsage ( string $usage )
$usage string

configure() protected method

配置指令
protected configure ( )

execute() protected method

执行指令
See also: setCode()
protected execute ( Input $input, Output $output ) : null | integer
$input Input
$output Output
return null | integer

getAliases() public method

获取别名
public getAliases ( ) : array
return array

getConsole() public method

获取控制台
public getConsole ( ) : Console
return think\Console

getDefinition() public method

获取参数定义
public getDefinition ( ) : Definition
return think\console\input\Definition

getDescription() public method

获取描述
public getDescription ( ) : string
return string

getHelp() public method

获取帮助信息
public getHelp ( ) : string
return string

getName() public method

获取指令名称
public getName ( ) : string
return string

getNativeDefinition() public method

获取当前指令的参数定义
public getNativeDefinition ( ) : Definition
return think\console\input\Definition

getProcessedHelp() public method

描述信息
public getProcessedHelp ( ) : string
return string

getSynopsis() public method

获取简介
public getSynopsis ( boolean $short = false ) : string
$short boolean 是否简单的
return string

getUsages() public method

获取用法介绍
public getUsages ( ) : array
return array

ignoreValidationErrors() public method

忽略验证错误

initialize() protected method

初始化
protected initialize ( Input $input, Output $output )
$input Input An InputInterface instance
$output Output An OutputInterface instance

interact() protected method

用户验证
protected interact ( Input $input, Output $output )
$input Input
$output Output

isEnabled() public method

是否有效
public isEnabled ( ) : boolean
return boolean

mergeConsoleDefinition() public method

合并参数定义
public mergeConsoleDefinition ( boolean $mergeArgs = true )
$mergeArgs boolean

run() public method

执行
See also: setCode()
See also: execute()
public run ( Input $input, Output $output ) : integer
$input Input
$output Output
return integer

setAliases() public method

设置别名
public setAliases ( string[] $aliases ) : Command
$aliases string[]
return Command

setCode() public method

设置执行代码
See also: execute()
public setCode ( callable $code ) : Command
$code callable callable(InputInterface $input, OutputInterface $output)
return Command

setConsole() public method

设置控制台
public setConsole ( Console $console = null )
$console think\Console

setDefinition() public method

设置参数定义
public setDefinition ( array | Definition $definition ) : Command
$definition array | think\console\input\Definition
return Command

setDescription() public method

设置描述
public setDescription ( string $description ) : Command
$description string
return Command

setHelp() public method

设置帮助信息
public setHelp ( string $help ) : Command
$help string
return Command

setName() public method

设置指令名称
public setName ( string $name ) : Command
$name string
return Command

Property Details

$input protected_oe property

protected Input,think\console $input
return Input

$output protected_oe property

protected Output,think\console $output
return Output