2017 © Pedro Peláez
 

library crony

PHP-based cron manager

image

pcrumm/crony

PHP-based cron manager

  • Monday, October 5, 2015
  • by pkcrumm
  • Repository
  • 0 Watchers
  • 1 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Crony

Crony is a PHP-based cron job framework. Add the master task to your crontab, and Crony will take care of all of the work necessary to ensure that your offline jobs run how you want them, when you want them., (*1)

Installation

  1. Install composer.
  2. Add Jobby to composer.json., (*2)

    "pcrumm/crony": "dev-master", (*3)

  3. Run composer install, (*4)

  4. Add the following to your crontab (see below for an example jobs.php:, (*5)

    * * * * * cd /path/to/project && php jobs.php 1>> /dev/null 2>&1, (*6)

Usage

jobs.php

jobs.php loads and runs Crony tasks, and should be referrenced from your crontab. It should include a call to the Crony::init() method, which takes a single argument: the namespace that your tasks reside under. This namespace should be PSR-0 autoloaded by composer, and by convention should exist in the src directory in your project's root. In the example below, all jobs are sub-directories of the src/PhilCrumm/ExampleTasks directory and thus exist in the \PhilCrumm\ExampleTasks namespace., (*7)

run();
?>

Example Task

Generally, Crony tasks will exist in the specified namespace, and will consist of a single PHP file (whose name matches its class) that implements the \Crony\TaskInterface interface. It will consist of at least two functions: config(), which returns a Jobby-formatted configuration array, and run(), which will be ran when it's time to run the cron task., (*8)

src/PhilCrumm/ExampleTasks/SayHello.php

 true,
            // Run every five minutes
            'schedule'  => '*/5 * * * *',
        );
    }

    /**
     * This function will be ran every time the above schedule is met.
     * We're just printing a string to the standard output (which will be
     * discarded per the crontab line earlier in the readme), but generally
     * you'd do something a little heftier.
     */
    public static function run() {
        print 'Hello, world!';
        return true;
    }
}
?>

Features

Crony is a wrapper around Jobby, and provides all of the features included in Jobby., (*9)

Particularly, Crony suggests a convention (rather than configuration) for cron jobs., (*10)

Credits

Crony is a tool built-upon Gerard Sychay's wonderful Jobby., (*11)

The Versions

05/10 2015

dev-master

9999999-dev http://github.com/pcrumm/crony

PHP-based cron manager

  Sources   Download

MIT

The Requires

 

The Development Requires

cli cron