Automate tasks with Laravel 5

Asked

Viewed 1,589 times

7

Good morning Personal.

I need to create some tasks on my system that are executed automatically (such as a Cron Job). Example: Every day the system sends an email to system customers with the value of their charges, and those that are close to winning.

I read it here in Scheduler, but the documentation of the Laravel did not make it clear to me how it works. Would anyone know better explain to me how this feature works? how I create tasks according to my need?

1 answer

8


Start by adding an entry to cron that runs the command php artisan schedule:run every minute.

So you can use it in many ways:

Commands:

$schedule->command('cache:clear')
    ->hourly()
    ->sendOutputTo($filePath)
    ->emailOutputTo('[email protected]'); 

Methods of a class:

$schedule->call('SomeClass@method')->dailyAt('10:00');

Anonymous function:

$schedule->call(function(){
    //.. 
})->everyThirtyMinutes();

Terminal command:

$schedule->terminal('gulp task')->fridays()->when(function(){ 
    return true;
});

Source: https://laravel-news.com/2014/11/laravel-5-scheduler/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.