Eric Barnes has a longer write up on this, so I’ll just keep it short:

5.0 is introducing a pretty incredible cron-style scheduler (similar to Indatus’ Dispatcher) built into the core. Just point a cron job that’s scheduled once a minute at artisan schedule:run and you’re good to go.

* * * * * php /path/to/artisan schedule:run 1>> /dev/null 2>&1

For example, you can now bind the following to clear your auth reminders daily:

$schedule
    ->command('auth:clear-reminders')
    ->daily()
    ->sendOutputTo($logPath)
    ->emailOutputTo('[email protected]');

You can use commmand() to call artisan commands, call to call methods or functions, or terminal() to run command line scripts:

$schedule->call('[email protected]')->twiceDaily();
$schedule->call(function() {
    // Do stuff
})->everyFiveMinutes();
$schedule->terminal('cp oldThing newThing')->dailyAt('8:00');

You can also use a callback to decide when something will or won’t run, using when() or skip():

$schedule
    ->call('[email protected]r')
    ->weekdays()
    ->skip(function(TypeHintedDeciderClass $decider)
    {
        return $decider->isHoliday();
    }
);

This is just a quick introduction, though; check out Eric’s post for a fuller rundown: Laravel 5 Scheduler on Laravel-News



Source link https://mattstauffer.com/blog/laravel-5.0-event-

LEAVE A REPLY

Please enter your comment!
Please enter your name here