Skip to content

ZiyaVakhobov/yii-cron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yii cron package


Installation

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.


Configuration

Before using you must migrate

php yii migrate --migrationPath="@vendor/ziya/yii-cron/src/migrations

Usage

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();
?>