2017 © Pedro Peláez
 

library scheduler

PHP job scheduler. (Cronjob tasker)

image

10quality/scheduler

PHP job scheduler. (Cronjob tasker)

  • Tuesday, May 30, 2017
  • by amostajo
  • Repository
  • 3 Watchers
  • 1 Stars
  • 55 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Scheduler

Latest Stable Version Total Downloads License, (*1)

PHP job scheduler. (Cronjob tasker), (*2)

Installing

Via composer:, (*3)

composer require 10quality/scheduler

Usage

Scheduler

Create a php file that will be called by cronjob, Sample, and include the following code lines:, (*4)

// 1) LOAD COMPOSER AUTOLOAD OR BOOTSTRAP FIRST

// 2)
use Scheduler\Scheduler;

Init scheduler with the required configuration:, (*5)

Scheduler::ready([
    'jobs'      => ['path' => __DIR__.'/jobs'],
    'session'   => ['driver' => 'file', 'path'=>__DIR__.'/.tmp'],
]);

NOTE: Scheduler requires a defined jobs path (where jobs are located) and the session driver/settings to use to handle intervals (the package only supports file atm)., (*6)

Register your jobs and execution interval., (*7)

Scheduler::ready([...])
    ->job('MyJob', function($task) {
        return $task->daily();
    });

Start scheduler:, (*8)

Scheduler::ready([...])
    ->job(...)
    ->start();

Then setup a cronjob task to run scheduler, as follows:, (*9)

* * * * * php /path/to/scheduler-file.php >> /dev/null 2>&1

Jobs

Scheduler runs jobs written in PHP. A job is a PHP class extended from Scheduler\Base\Job class. Once a job is registered in the scheduler, it will call to the execute() function in runtime, Sample., (*10)

Create a job mimicking the following example:, (*11)

use Scheduler\Base\Job;

class MyJob extends Job
{
    public function execute()
    {
        // My code here...
    }
}

For the example above, the job file must be named MyJob.php and must be stored in the jobs path., (*12)

Intervals

Execution intervals are defined when registering a job:, (*13)

Scheduler::ready([...])
    ->job('MyJob', function($task) {
        // Here we define the task interval
        return $task->daily();
    });

Available intervals:, (*14)

// On every execution
$task->now();

// Daily
$task->daily();

// Weekly
$task->weekly();

// Monthly
$task->monthly();

// Every minute
$task->everyMinute();

// Every 5 minutes
$task->everyFiveMinutes();

// Every 10 minutes
$task->everyTenMinutes();

// Every 30 minutes
$task->everyHalfHour();

// Every hour
$task->everyHour();

// Every 12 hours
$task->everyTwelveHours();

Requirements

  • PHP >= 5.4

Coding guidelines

PSR-4., (*15)

LICENSE

The MIT License (MIT), (*16)

Copyright (c) 2016 10Quality., (*17)

The Versions

30/05 2017

v1.0.x-dev

1.0.9999999.9999999-dev https://github.com/10quality/scheduler

PHP job scheduler. (Cronjob tasker)

  Sources   Download

MIT

The Requires

 

The Development Requires

php events task jobs cronjob scheduler tasker schedules

30/05 2017

v1.0.2

1.0.2.0 https://github.com/10quality/scheduler

PHP job scheduler. (Cronjob tasker)

  Sources   Download

MIT

The Requires

 

The Development Requires

php events task jobs cronjob scheduler tasker schedules

24/06 2016

v1.0.1

1.0.1.0 https://github.com/10quality/scheduler

PHP job scheduler. (Cronjob tasker)

  Sources   Download

MIT

The Requires

 

The Development Requires

php events task jobs cronjob scheduler tasker schedules

23/06 2016

dev-master

9999999-dev https://github.com/10quality/scheduler

PHP job scheduler. (Cronjob tasker)

  Sources   Download

MIT

The Requires

 

The Development Requires

php events task jobs cronjob scheduler tasker schedules

23/06 2016

v1.0.0

1.0.0.0 https://github.com/10quality/scheduler

PHP job scheduler. (Cronjob tasker)

  Sources   Download

MIT

The Requires

 

The Development Requires

php events task jobs cronjob scheduler tasker schedules