PHP code example of rewieer / taskschedulerbundle

1. Go to this page and download the library: Download rewieer/taskschedulerbundle 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/ */

    

rewieer / taskschedulerbundle example snippets


// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Rewieer\TaskSchedulerBundle\RewieerTaskSchedulerBundle(),
    // ...
);

use Rewieer\TaskSchedulerBundle\Task\AbstractScheduledTask;
use Rewieer\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 Rewieer\TaskSchedulerBundle\Task\AbstractScheduledTask;
use Rewieer\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
  }
}