扩展注册自定义命令到 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);
});
}

扩展注册自定义命令到 Laravel
https://celaraze.com/2021/08/18/laravel-extension-register-custom-console/
作者
celaraze
发布于
2021年8月18日
许可协议