basebuilder/scheduling

CRON like behaviour with PHP. You can replace many cron jobs with a single entry when using this

dev-master 2017-06-19 07:58 UTC

README

basebuilder/scheduling replicates CRON behaviour in PHP.

Latest Stable Version Total Downloads License Scrutinizer Code Quality Code Coverage Build Status

Install

Via Composer

$ composer require basebuilder/scheduling

Usage

Let's say you create /var/php/cron.php with the following contents:

<?php

// load autoloader
require_once(__DIR__ . '/vendor/autoload.php');

// Define your schedule
$schedule = new \Basebuilder\Scheduling\Schedule();
$schedule
    ->run('echo "hello world"')
    ->everyFiveMinutes();

// run all commands that need to be ran
foreach ($schedule->dueEvents() as $event) {
    $event->run();
}

You can now easily add a single entry to the crontab: * * * * * /path/to/php /var/php/cron.php

Other scheduling types

The Schedule can also run a PHP callables:

$schedule
    ->run(function () { echo "hello world from a function"; })
    ->daily();

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.