我想用一个程序(Freescout)作为一个Laravel程序。它很好,除了我必须做一个cron的工作:* * * * * php /var/userdata/web/.../website/helpdesk/artisan schedule:run >> /dev/null 2>&1
,但是我不能在终端上运行它,不能使用任何CLI,只需设置一个Cron来运行PHP脚本。(共享主机服务器)。
因此,我创建了一个名为artisan_schedule_runner.php的文件--它很简单:
Route::get('/foo', function () {
Artisan::call('schedule:run >> /dev/null 2>&1');
//
});我应该如何扩展我的代码以使其工作?
提前谢谢你!
发布于 2020-05-22 12:15:45
我似乎找到了解决办法,并解决了我的问题:Artisan::call() outside the Laravel framework
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$input = new Symfony\Component\Console\Input\ArrayInput(['command' => 'schedule:run']);
$output = new Symfony\Component\Console\Output\StreamOutput(fopen('output.log', 'a', false));
$status = $kernel->handle( $input, $output );运行预先定义的时间表。
https://stackoverflow.com/questions/61944558
复制相似问题