app\Console\Kernel.php
文件里面有个schedule方法,可以调用command()执行命令行指令:
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->hourly();
}
问题:
我想在自己写的控制器里面使用command()方法,应该怎么写呢?比如:
class TestController extends Controller
{
public function test()
{
//我想使用command(),不是定时调用,而是这个test()方法执行时就生效,应该怎么写?
}
}
使用
Artisan::call
调用。多看看文档吧https://d.laravel-china.org/docs/5.4/artisan#程序内部调用命令