Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

BitWeb/zf3-cron-module

Repository files navigation

Build Status Coverage Status ZF3 implementation for Cron/Cron

Working with Zend Framework 2? We've got you covered.

Installation

Installation of CronModule uses composer. For composer documentation, please refer to getcomposer.org.

php composer.phar require bitweb/zf3-cron-module:1.0.*

or add to your composer.json

"require": {
  "bitweb/zf3-cron-module": "1.0.*"
}

Then add BitWeb\CronModule to your config/application.config.php

Installation without composer is not officially supported, and requires you to install and autoload the dependencies specified in the composer.json.

Configuration

Add to your configuration:

'cronModule' => [
    'phpPath'    => 'php',
    'scriptPath' => '/path/to/application/public/folder/',
    'jobs'       => [
        [
            'command'  => 'index.php application cron do-job',
            'schedule' => '* * * * *'
        ],
        [
            'command'  => 'index.php application cron do-another-job',
            'schedule' => '0 * * * *'
        ]
    ]
]

General options:

Option Description
phpPath path to the php executable, usually "php"
scriptPath path to your applications public folder, defaults to your root aplication public folder
jobs an array of jobs and their schedules
timeout timeout for the cron job

Options for cron jobs:

Option Description
command the php script command to be run
schedule A valid Cron schedule

You can also get the configutation file sample from config folder config/cronModule.config.php.dist.

Run cron job from command line

php index.php cron module start