ThinkPHP5


think\console\Command
library\think\console\Command.php at line 19

Class Command

Command
All Known Subclasses:
think\console\command\optimize\Autoload think\console\command\Build think\console\command\Clear think\console\command\optimize\Config think\console\command\Help think\console\command\Lists think\console\command\Make think\console\command\optimize\Route think\console\command\optimize\Schema

public class Command


Constructor Summary
void

__construct(string|null name)

构造方法

Method Summary
void

ignoreValidationErrors()

忽略验证错误

void

setConsole(Console console)

设置控制台

Console

getConsole()

获取控制台

bool

isEnabled()

是否有效

protected void

configure()

配置指令

protected null|int

execute(Input input, Output output)

执行指令

protected void

interact(Input input, Output output)

用户验证

protected void

initialize(Input input, Output output)

初始化

int

run(Input input, Output output)

执行

Command

setCode(callable code)

设置执行代码

void

mergeConsoleDefinition(bool mergeArgs)

合并参数定义

Command

setDefinition(array|Definition definition)

设置参数定义

Definition

getDefinition()

获取参数定义

Definition

getNativeDefinition()

获取当前指令的参数定义

Command

addArgument(string name, int mode, string description, mixed default)

添加参数

Command

addOption(string name, string shortcut, int mode, string description, mixed default)

添加选项

Command

setName(string name)

设置指令名称

string

getName()

获取指令名称

Command

setDescription(string description)

设置描述

string

getDescription()

获取描述

Command

setHelp(string help)

设置帮助信息

string

getHelp()

获取帮助信息

string

getProcessedHelp()

描述信息

Command

setAliases(string aliases)

设置别名

array

getAliases()

获取别名

string

getSynopsis(bool short)

获取简介

$this

addUsage(string usage)

添加用法介绍

array

getUsages()

获取用法介绍

Constructor Detail

library\think\console\Command.php at line 48

__construct

public void __construct(string|null name)

构造方法

Parameters:
name - 命令名称,如果没有设置则比如在 configure() 里设置
Throws:
\LogicException
Api.

Method Detail

library\think\console\Command.php at line 66

ignoreValidationErrors

public void ignoreValidationErrors()

忽略验证错误


library\think\console\Command.php at line 75

setConsole

public void setConsole(Console console)

设置控制台


library\think\console\Command.php at line 85

getConsole

public Console getConsole()

获取控制台

Api.

library\think\console\Command.php at line 94

isEnabled

public bool isEnabled()

是否有效


library\think\console\Command.php at line 102

configure

protected void configure()

配置指令


library\think\console\Command.php at line 114

execute

protected null|int execute(Input input, Output output)

执行指令

Throws:
\LogicException
See Also:
setCode()

library\think\console\Command.php at line 124

interact

protected void interact(Input input, Output output)

用户验证


library\think\console\Command.php at line 133

initialize

protected void initialize(Input input, Output output)

初始化

Parameters:
input - An InputInterface instance
output - An OutputInterface instance

library\think\console\Command.php at line 146

run

public int run(Input input, Output output)

执行

Throws:
\Exception
See Also:
setCode()
execute()

library\think\console\Command.php at line 188

setCode

public Command setCode(callable code)

设置执行代码

Parameters:
code - callable(InputInterface $input, OutputInterface $output)
Throws:
\InvalidArgumentException
See Also:
execute()

library\think\console\Command.php at line 210

mergeConsoleDefinition

public void mergeConsoleDefinition(bool mergeArgs)

合并参数定义


library\think\console\Command.php at line 239

setDefinition

public Command setDefinition(array|Definition definition)

设置参数定义

Api.

library\think\console\Command.php at line 257

getDefinition

public Definition getDefinition()

获取参数定义

Api.

library\think\console\Command.php at line 266

getNativeDefinition

public Definition getNativeDefinition()

获取当前指令的参数定义


library\think\console\Command.php at line 279

addArgument

public Command addArgument(string name, int mode, string description, mixed default)

添加参数

Parameters:
name - 名称
mode - 类型
description - 描述
default - 默认值

library\think\console\Command.php at line 295

addOption

public Command addOption(string name, string shortcut, int mode, string description, mixed default)

添加选项

Parameters:
name - 选项名称
shortcut - 别名
mode - 类型
description - 描述
default - 默认值

library\think\console\Command.php at line 308

setName

public Command setName(string name)

设置指令名称

Throws:
\InvalidArgumentException

library\think\console\Command.php at line 321

getName

public string getName()

获取指令名称


library\think\console\Command.php at line 331

setDescription

public Command setDescription(string description)

设置描述


library\think\console\Command.php at line 342

getDescription

public string getDescription()

获取描述


library\think\console\Command.php at line 352

setHelp

public Command setHelp(string help)

设置帮助信息


library\think\console\Command.php at line 363

getHelp

public string getHelp()

获取帮助信息


library\think\console\Command.php at line 372

getProcessedHelp

public string getProcessedHelp()

描述信息


library\think\console\Command.php at line 394

setAliases

public Command setAliases(string aliases)

设置别名

Throws:
\InvalidArgumentException

library\think\console\Command.php at line 413

getAliases

public array getAliases()

获取别名


library\think\console\Command.php at line 423

getSynopsis

public string getSynopsis(bool short)

获取简介

Parameters:
short - 是否简单的

library\think\console\Command.php at line 439

addUsage

public $this addUsage(string usage)

添加用法介绍


library\think\console\Command.php at line 454

getUsages

public array getUsages()

获取用法介绍


ThinkPHP5