1. Go to this page and download the library: Download webtoolsnz/yii2-scheduler 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/ */
webtoolsnz / yii2-scheduler example snippets
Event::on(AlphabetTask::className(), AlphabetTask::EVENT_BEFORE_RUN, function ($event) {
Yii::trace($event->task->className . ' is about to run');
});
Event::on(AlphabetTask::className(), AlphabetTask::EVENT_AFTER_RUN, function ($event) {
Yii::trace($event->task->className . ' just ran '.($event->success ? 'successfully' : 'and failed'));
});
$application->on(\webtoolsnz\scheduler\events\SchedulerEvent::EVENT_AFTER_RUN, function ($event) {
if (!$event->success) {
foreach($event->exceptions as $exception) {
throw $exception;
}
}
});