PHP code example of boehsermoe / luya-module-scheduler

1. Go to this page and download the library: Download boehsermoe/luya-module-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/ */

    

boehsermoe / luya-module-scheduler example snippets


return [
    'modules' => [
        // ...
	'scheduleradmin' => [
            'class' => 'luya\scheduler\admin\Module',
        ],
        'scheduler' => [
            'class' => 'luya\scheduler\frontend\Module',
	    'accessToken' => '{token for web access}' // optional for webcron
        ],
        // ...
    ],
];

class ExampleJob extends \luya\scheduler\models\BaseJob
{
    public function run()
    {
        // Do your job.
    }
}

class ExampleTextJob extends \luya\scheduler\models\BaseJob
{
    public $text;

    public function rules()
    {
        return array_merge(parent::rules(), [
            [['text'], '            'text' => 'text',
        ];
    }

    public function run()
    {
        // Do your job
	//
	// echo $this->text;
    }
}

[
...
 'on afterRequest' => function() {
     if (!$this->isCli()) {
         Yii::$app->getModule('scheduler')->runExpiredJobsAsync();
     }
 },
...
]