I am following this tutorial每分钟安排一项功能。以下是我在localhost上的代码。任务计划:Laravel 5.3
class Kernel extends ConsoleKernel
{
protected $commands = [
'App\Console\Commands\Inspire',
];
protected function schedule(Schedule $schedule)
{
$schedule->call($this->WriteFile())->everyMinute();
}
protected function commands()
{
require base_path('routes/console.php');
}
private function WriteFile() {
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
fclose($myfile);
}
}
我看到txt文件没有显示内容。我把公共文件夹中的txt文件。我错过了什么吗?
您是否添加了cron项到你的服务器? – istaro
这是关于localhost的。 – Pankaj