I am following this tutorial to schedule a function every minute. Below is my code.
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);
}
}
I saw that the txt file is not showing the contents. i placed the txt file in public folder. Am I missing something?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire