Properties

$input

$input : \think\console\Input

Type

Input

$output

$output : \think\console\Output

Type

Output

$worker

$worker : \think\queue\Worker

The queue worker instance.

Type

Worker

$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 —

execute()

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

Execute the console command.

Parameters

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

Returns

int|null|void —

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 —

stop()

stop() : void

停止执行任务的守护进程.

configure()

configure() : mixed

配置指令

Returns

mixed —

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 —

output()

output(mixed  $response) : mixed

Parameters

mixed $response

Returns

mixed —

daemon()

daemon(string  $queue = null, int  $delay, int  $memory = 128, int  $sleep = 3, int  $maxTries) : array

启动一个守护进程执行任务.

Parameters

string $queue
int $delay
int $memory
int $sleep
int $maxTries

Returns

array —

runNextJobForDaemon()

runNextJobForDaemon(string  $queue, int  $delay, int  $sleep, int  $maxTries) : void

以守护进程的方式执行下个任务.

Parameters

string $queue
int $delay
int $sleep
int $maxTries

getTimestampOfLastQueueRestart()

getTimestampOfLastQueueRestart() : int|null

获取上次重启守护进程的时间

Returns

int|null —

queueShouldRestart()

queueShouldRestart(int|null  $lastRestart) : bool

检查是否要重启守护进程

Parameters

int|null $lastRestart

Returns

bool —

memoryExceeded()

memoryExceeded(int  $memoryLimit) : bool

检查内存是否超出

Parameters

int $memoryLimit

Returns

bool —

getExceptionHandler()

getExceptionHandler() : \think\exception\Handle

获取异常处理实例

Returns

\think\exception\Handle —

validateName()

validateName(string  $name) : mixed

验证指令名称

Parameters

string $name

Throws

\InvalidArgumentException

Returns

mixed —