The preferred way to install this extension is through composer.
Either run
composer require ziya/yii-cron
or add
"ziya/yii-cron": "*"
to the require section of your composer.json
file.
Before using you must migrate
php yii migrate --migrationPath="@vendor/ziya/yii-cron/src/migrations
Send sms cron
<?php
class SendSmsCron extends \Ziya\YiiCron\BaseCron
{
public static function key(){
return 'send_sms_cron'
}
public function execute(){
$sms = new Sms();
$sms->phone_number = 123456789;
$sms->body = "Hello world !";
$sms->send();
}
}
?>
Running crons
<?php
$list = [
SendSmsCron::class
];
$cron = new \Ziya\YiiCron\CronList($list);
$cron->execute();
?>