Properties

$input

$input : \think\console\Input

Type

Input

$output

$output : \think\console\Output

Type

Output

$type

$type

$console

$console : \think\Console

Type

Console

$name

$name

$aliases

$aliases

$definition

$definition

$help

$help

$description

$description

$ignoreValidationErrors

$ignoreValidationErrors

$consoleDefinitionMerged

$consoleDefinitionMerged

$consoleDefinitionMergedWithArgs

$consoleDefinitionMergedWithArgs

$code

$code

$synopsis

$synopsis

$usages

$usages

Methods

__construct()

__construct(string|null  $name = null) : mixed

构造方法

Parameters

string|null $name

命令名称,如果没有设置则比如在 configure() 里设置

Throws

\LogicException

Returns

mixed —

ignoreValidationErrors()

ignoreValidationErrors() : mixed

忽略验证错误

Returns

mixed —

setConsole()

setConsole(\think\Console  $console = null) : mixed

设置控制台

Parameters

\think\Console $console

Returns

mixed —

getConsole()

getConsole() : \think\Console

获取控制台

Returns

\think\Console —

isEnabled()

isEnabled() : bool

是否有效

Returns

bool —

run()

run(\think\console\Input  $input, \think\console\Output  $output) : int

执行

Parameters

\think\console\Input $input
\think\console\Output $output

Throws

\Exception

Returns

int —

setCode()

setCode(callable  $code) : \think\console\Command

设置执行代码

Parameters

callable $code

callable(InputInterface $input, OutputInterface $output)

Throws

\InvalidArgumentException

Returns

\think\console\Command —

mergeConsoleDefinition()

mergeConsoleDefinition(bool  $mergeArgs = true) : mixed

合并参数定义

Parameters

bool $mergeArgs

Returns

mixed —

setDefinition()

setDefinition(array|\think\console\input\Definition  $definition) : \think\console\Command

设置参数定义

Parameters

array|\think\console\input\Definition $definition

Returns

\think\console\Command —

getDefinition()

getDefinition() : \think\console\input\Definition

获取参数定义

Returns

\think\console\input\Definition —

getNativeDefinition()

getNativeDefinition() : \think\console\input\Definition

获取当前指令的参数定义

Returns

\think\console\input\Definition —

addArgument()

addArgument(string  $name, int  $mode = null, string  $description = '', mixed  $default = null) : \think\console\Command

添加参数

Parameters

string $name

名称

int $mode

类型

string $description

描述

mixed $default

默认值

Returns

\think\console\Command —

addOption()

addOption(string  $name, string  $shortcut = null, int  $mode = null, string  $description = '', mixed  $default = null) : \think\console\Command

添加选项

Parameters

string $name

选项名称

string $shortcut

别名

int $mode

类型

string $description

描述

mixed $default

默认值

Returns

\think\console\Command —

setName()

setName(string  $name) : \think\console\Command

设置指令名称

Parameters

string $name

Throws

\InvalidArgumentException

Returns

\think\console\Command —

getName()

getName() : string

获取指令名称

Returns

string —

setDescription()

setDescription(string  $description) : \think\console\Command

设置描述

Parameters

string $description

Returns

\think\console\Command —

getDescription()

getDescription() : string

获取描述

Returns

string —

setHelp()

setHelp(string  $help) : \think\console\Command

设置帮助信息

Parameters

string $help

Returns

\think\console\Command —

getHelp()

getHelp() : string

获取帮助信息

Returns

string —

getProcessedHelp()

getProcessedHelp() : string

描述信息

Returns

string —

setAliases()

setAliases(string[]  $aliases) : \think\console\Command

设置别名

Parameters

string[] $aliases

Throws

\InvalidArgumentException

Returns

\think\console\Command —

getAliases()

getAliases() : array

获取别名

Returns

array —

getSynopsis()

getSynopsis(bool  $short = false) : string

获取简介

Parameters

bool $short

是否简单的

Returns

string —

addUsage()

addUsage(string  $usage) : $this

添加用法介绍

Parameters

string $usage

Returns

$this —

getUsages()

getUsages() : array

获取用法介绍

Returns

array —

configure()

configure() : mixed

配置指令

Returns

mixed —

execute()

execute(\think\console\Input  $input, \think\console\Output  $output) : null|int

执行指令

Parameters

\think\console\Input $input
\think\console\Output $output

Returns

null|int —

interact()

interact(\think\console\Input  $input, \think\console\Output  $output) : mixed

用户验证

Parameters

\think\console\Input $input
\think\console\Output $output

Returns

mixed —

initialize()

initialize(\think\console\Input  $input, \think\console\Output  $output) : mixed

初始化

Parameters

\think\console\Input $input

An InputInterface instance

\think\console\Output $output

An OutputInterface instance

Returns

mixed —

table()

table(\think\console\Table  $table) : string

输出表格

Parameters

\think\console\Table $table

Returns

string —

getStub()

getStub() : mixed

Returns

mixed —

buildClass()

buildClass(mixed  $name) : mixed

Parameters

mixed $name

Returns

mixed —

getPathName()

getPathName(mixed  $name) : mixed

Parameters

mixed $name

Returns

mixed —

getClassName()

getClassName(mixed  $name) : mixed

Parameters

mixed $name

Returns

mixed —

getNamespace()

getNamespace(mixed  $appNamespace, mixed  $module) : mixed

Parameters

mixed $appNamespace
mixed $module

Returns

mixed —

validateName()

validateName(string  $name) : mixed

验证指令名称

Parameters

string $name

Throws

\InvalidArgumentException

Returns

mixed —