扩展注册自定义命令到 Laravel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
* @var string[] 自定义命令清单
*/
protected $commands = [
Console\InitAdminMenuCommand::class,
Console\InstallCommand::class,
];

/**
* 注册自定义命令至Laravel的命令中
*
* @param array|mixed $commands
* @return void
*/
public function commands($commands)
{
$commands = is_array($commands) ? $commands : func_get_args();

Application::starting(function ($artisan) use ($commands) {
$artisan->resolveCommands($commands);
});
}

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!