PHP code example of proklung / task-scheduler-bundle

1. Go to this page and download the library: Download proklung/task-scheduler-bundle 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/ */

    

proklung / task-scheduler-bundle example snippets


use Prokl\TaskSchedulerBundle\Task\AbstractScheduledTask;
use Prokl\TaskSchedulerBundle\Task\Schedule;

class Task extends AbstractScheduledTask {
  protected function initialize(Schedule $schedule) {
    $schedule
      ->everyMinutes(5); // Perform the task every 5 minutes
  }

  public function run() {
    // Do stuff
  }
}

use Prokl\TaskSchedulerBundle\Task\AbstractScheduledTask;
use Prokl\TaskSchedulerBundle\Task\Schedule;

class Task extends AbstractScheduledTask {
  protected function initialize(Schedule $schedule) {
    $schedule
      ->minutes(0)
      ->everyHours(5); // Perform the task every 5 hours on minute 0
      
    // Or if you want to perform your task at midnight every day
    // $schedule->minutes(0)->hours(0)->daily();
    
    // Or schedule your task to run once at 9AM daily (this is effectively the same as daily() above)
    // $schedule->minutes(0)->hours(9);
  }

  public function run() {
    // Do stuff
  }
}