1. Go to this page and download the library: Download yii2mod/yii2-scheduling 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/ */
yii2mod / yii2-scheduling example snippets
$schedule->call(function()
{
// Do some task...
})->hourly();
/**
* @var \yii2mod\scheduling\Schedule $schedule
*/
// Place here all of your cron jobs
// This command will execute ls command every five minutes
$schedule->exec('ls')->everyFiveMinutes();
// This command will execute migration command of your application every hour
$schedule->command('migrate')->hourly();
// This command will call callback function every day at 10:00
$schedule->call(function(\yii\console\Application $app) {
// Some code here...
})->dailyAt('10:00');
public function bootstrap(Application $app)
{
if ($app instanceof \yii\console\Application) {
if ($app->has('schedule')) {
/** @var omnilight\scheduling\Schedule $schedule */
$schedule = $app->get('schedule');
// Place all your shedule command below
$schedule->command('my-extension-command')->dailyAt('12:00');
}
}
}