stagem/zfc-cron

ZF cron module based on https://github.com/yalesov/zf2-cron

dev-master 2019-02-15 12:48 UTC

This package is not auto-updated.

Last update: 2024-04-14 03:43:45 UTC


README

Config based wrapper for Yalesov\Cron module, which allow use config for register cron jobs. Simply speaking Zend Framework way for module implementation.

Installation

composer require stagem/zfc-cron

Then add Yalesov\Cron and Stagem\ZfcCron to the modules key in (app root)/config/modules.config.* in that order.

Usage

//config/module.config.php

return [
    'cron' => [
        'jobs' => [
            [
                'alias' => 'unique-cron-job-code',
                'frequency' => '*/1 * * * *',
                'callback' => 'Stagem\Amazon\Service\ParserService::parse',
                'properties' => [
                    'task' => 'foo',
                ],
            ],
        ],
    ],
];

Options

alias

Unique stringable code of cron Job. By this code you can identify cron Job in log or somewhere else.

frequency

Cron schedule time. Explanation

callback

Any valid PHP callback. If callback passed as namespace notation and a method is not static Cron will try to get the object through ServiceManager.

Notice. Static method usage is not preferable. Use ServiceManager for maximum flexibility.

properties

Additional properties which will be passed to callback

Other option you can read here.