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