Closed pixeline closed 8 years ago
App->job2
contains your business code. It could be anything: send automated emails, auto-update order status, archive old data, send reports, run a watchdog, auto-deploy website, etc.
The code handler is not expected to return anything. It is just passed one argument: the framework instance.
Here's a simple "hello world" example:
class Hello {
function world(Base $f3) {
$str=sprintf('Hello world, it\'s %s at the moment.',strftime('%X'));
$f3->write($f3->TEMP.'hello-world.txt',$str,TRUE);
}
}
$cron=Cron::instance();
$cron->set('HelloWorld','Hello->world','* * * * *'); // runs every minute
Every minute, this job will append one line to the file hello-world.txt
located in the TEMP
folder.
Awesome, thank you! And thank you for such a prompt reply!
I'm not sure I understand how to define the job. For instance, i have this line:
What function would App->job2 actually call ? Could you provide a brief "hello world" example?
My confusion is probably due to the fact that I usually use route() with anonymous functions. I guess for this syntax example to work, I'd need to create an $App class with job2() as method?
Thank you!!!