PHP code example of yiicod / yii2-cron

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

    

yiicod / yii2-cron example snippets


public function behaviors()
{
    return array(
        'LockUnLockBehavior' => array(
            'class' => 'yiicod\cron\commands\behaviors\LockUnLockBehavior',
            'timeLock' => 0 //Set time lock duration for command in seconds
        )
    );
}

class AwesomeCommand extends DaemonController
{
    /**
     * Daemon name
     *
     * @return string
     */
    protected function daemonName(): string
    {
        return 'mail-queue';
    }

    /**
     * Run send mail
     */
    public function worker()
    {
        // Some logic that will be repeateble 
    }
}