1. Go to this page and download the library: Download mertyildiran/dispatcher library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mertyildiran / dispatcher example snippets
use Indatus\Dispatcher\Scheduling\ScheduledCommand;
use Indatus\Dispatcher\Scheduling\Schedulable;
use Indatus\Dispatcher\Drivers\DateTime\Scheduler;
class MyCommand extends ScheduledCommand {
public function schedule(Schedulable $scheduler)
{
//every day at 4:17am
return $scheduler
->daily()
->hours(4)
->minutes(17);
}
}
use Indatus\Dispatcher\Scheduling\ScheduledCommand;
use Indatus\Dispatcher\Scheduling\Schedulable;
use Indatus\Dispatcher\Drivers\DateTime\Scheduler;
/**
* When a command should run
*
* @param Scheduler $scheduler
*
* @return Scheduler
*/
public function schedule(Schedulable $scheduler)
{
return $scheduler;
}
public function user()
{
return 'backup';
}
public function environment()
{
return ['development','staging'];
}
public function runInMaintenanceMode()
{
return true;
}
public function schedule(Schedulable $scheduler)
{
return [
// 5am Mon-Fri
$scheduler->everyWeekday()->hours(5),
// 2am every Saturday
App::make(get_class($scheduler))
->daysOfTheWeek(Scheduler::SATURDAY)
->hours(2)
];
}
public function schedule(Schedulable $scheduler)
{
//every day at 4:17am
return $scheduler->daily()->hours(4)->minutes(17);
}
public function schedule(Schedulable $scheduler)
{
//every Tuesday/Thursday at 5:03am
return $scheduler->daysOfTheWeek([
Scheduler::TUESDAY,
Scheduler::THURSDAY
])->hours(5)->minutes(3);
}
public function schedule(Schedulable $scheduler)
{
//the second and third Tuesday of every month at 12am
return $scheduler->monthly()->week([2, 3])->daysOfTheWeek(Day::TUESDAY);
}
$ php artisan scheduled:run --debug
Running commands...
backup:avatars: No schedules were due
command:name: No schedules were due
myTestCommand:name: No schedules were due
cache:clean: /usr/bin/env php /Users/myUser/myApp/artisan cache:clean > /dev/null &
mail:subscribers: /usr/bin/env php /Users/myUser/myApp/artisan mail:subscribers > /dev/null &
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.