PHPackages                             10quality/scheduler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. 10quality/scheduler

ActiveLibrary[Queues &amp; Workers](/categories/queues)

10quality/scheduler
===================

PHP job scheduler. (Cronjob tasker)

v1.0.4(6y ago)1115MIT

Since Jun 23Compare

[ Source](https://github.com/10quality/scheduler)[ Packagist](https://packagist.org/packages/10quality/scheduler)[ Docs](https://github.com/10quality/scheduler)[ RSS](/packages/10quality-scheduler/feed)WikiDiscussions Synced yesterday

READMEChangelog (5)Dependencies (2)Versions (7)Used By (0)

Scheduler
=========

[](#scheduler)

[![Latest Stable Version](https://camo.githubusercontent.com/fe814bac869495dc9187e0dd2d12f3d9ec49f98e241751b7b497d03a5514d2f3/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7363686564756c65722f762f737461626c65)](https://packagist.org/packages/10quality/scheduler)[![Total Downloads](https://camo.githubusercontent.com/c6d0427ee789553ace6fd1c5c610a73b7f5d83c436ae7c0d6f3849d90b9b6545/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7363686564756c65722f646f776e6c6f616473)](https://packagist.org/packages/10quality/scheduler)[![License](https://camo.githubusercontent.com/a00e8e321848d8b7e661526ea0eab5cceba1a0eff9787d88fe6c7703d8e71ca6/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7363686564756c65722f6c6963656e7365)](https://packagist.org/packages/10quality/scheduler)

PHP job scheduler. (Cronjob tasker)

Installing
----------

[](#installing)

Via composer:

```
composer require 10quality/scheduler
```

Usage
-----

[](#usage)

### Scheduler

[](#scheduler-1)

Create a php file that will be called by cronjob, [Sample](https://github.com/10quality/scheduler/blob/v1.0/tests/_environment/scheduler.php), and include the following code lines:

```
// 1) LOAD COMPOSER AUTOLOAD OR BOOTSTRAP FIRST

// 2)
use Scheduler\Scheduler;
```

Init scheduler with the required configuration:

```
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).

Register your jobs and execution interval.

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

Start scheduler:

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

Then setup a cronjob task to run scheduler, as follows:

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

### Jobs

[](#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](https://github.com/10quality/scheduler/blob/v1.0/tests/_environment/jobs/TestJob.php).

Create a job mimicking the following example:

```
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`.

### Intervals

[](#intervals)

Execution intervals are defined when registering a job:

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

Available intervals:

```
// 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();

// Every 2 days
$task->everyTwoDays();

// Every 3 days
$task->everyThreeDays();

// Every XXX minutes (custom minutes)
// @param init $minutes Custome minutes interval
$task->custom($minutes);
```

### Events

[](#events)

You can define callable event handlers when configuring the scheduler, like in the following example:

```
Scheduler::ready([
    'jobs'      => ['path' => __DIR__.'/jobs'],
    'session'   => ['driver' => 'file', 'path'=>__DIR__.'/.tmp'],
    'events'    => [
                    'on_start' => function($microtime) {
                        // Do something during event
                    },
                    'on_job_start' => function($jobName, $microtime) {
                        if ($jobName === 'Job')
                            // Do something during event
                    }
                ],
]);
```

List of events (parameters can be used optionally):

Event keyParametersDescription`on_init`Triggered before session is validated.`on_start`*int* **$microtime**Triggered before executing any job.`on_finish`*int* **$microtime**Triggered after executing all jobs and saving session.`on_job_start`*string* **$jobName**, *int* **$microtime**Triggered before executing of a job.`on_job_finish`*string* **$jobName**, *int* **$microtime**Triggered after executing of job.### Handling Exceptions

[](#handling-exceptions)

Scheduler will run continuously without interruption. You can handle exceptions individually per job or globally to log them as needed.

#### Global Exception Handling

[](#global-exception-handling)

Add a `on_exception` callable handler in the scheduler's events configuration, like in the following example:

```
Scheduler::ready([
    'jobs'      => ['path' => __DIR__.'/jobs'],
    'session'   => ['driver' => 'file', 'path'=>__DIR__.'/.tmp'],
    'events'    => [
                    'on_exception' => function($e) {
                        // Do anything with exception
                        echo $e->getMessage();
                    }
                ],
]);
```

#### Job Exceptions

[](#job-exceptions)

Add a exception handling callable when defining the job task, like this:

```
Scheduler::ready([...])
    ->job('MyJob', function($task) {
        // Here we define the task interval
        return $task->daily()
            ->onException(function($e) {
                // Do anything with exception
                echo $e->getMessage();
            });
    });
```

To reset the job when an exception occurs and force it to be executed on the next run, indicate it on the task:

```
Scheduler::ready([...])
    ->job('MyJob', function($task) {
        // Here we define the task interval
        return $task->daily()
            ->canReset()
            ->onException(function(Exception $e) {
                // Do anything with exception
            });
    });
```

### Session

[](#session)

#### File

[](#file)

Indicate the folder where session file will be stored. Make sure this folder has the proper permissions.

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

#### Callable

[](#callable)

You can create your own session driver by extending from the [Session](https://github.com/10quality/scheduler/blob/v1.0/src/Contracts/Session.php) interface:

```
use Scheduler\Contracts\Session;

class MySessionDriver implements Session
{
    /*
     * See and develop required interface methods....
     */
}
```

Then, when initializing the scheduler, set the driver to `callable` and add the *callable* as second parameter, like the following example:

```
Scheduler::ready([
    'jobs'      => ['path' => __DIR__.'/jobs'],
    'session'   => [
                    'driver'    => 'callable',,
                    'callable'  => function() use(&$session) {
                        return MySessionDriver::load( $custom_options );
                    }
                ],
]);
```

Requirements
------------

[](#requirements)

- PHP &gt;= 5.4

Coding guidelines
-----------------

[](#coding-guidelines)

PSR-4.

LICENSE
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2016-2019 [10Quality](http://www.10quality.com).

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~248 days

Recently: every ~310 days

Total

6

Last Release

2418d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f2cdad4e398292477582ba8ec4ab02a96fa645cd620518a5bcf697cd788c96c3?d=identicon)[amostajo](/maintainers/amostajo)

---

Top Contributors

[![amostajo](https://avatars.githubusercontent.com/u/1645908?v=4)](https://github.com/amostajo "amostajo (11 commits)")

---

Tags

phpschedulereventstaskjobscronjobtaskerschedules

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/10quality-scheduler/health.svg)

```
[![Health](https://phpackages.com/badges/10quality-scheduler/health.svg)](https://phpackages.com/packages/10quality-scheduler)
```

###  Alternatives

[orisai/scheduler

Cron job scheduler - with locks, parallelism and more

4041.4k5](/packages/orisai-scheduler)[aboutcoders/job-bundle

A symfony bundle for asynchronous job processing.

2519.1k1](/packages/aboutcoders-job-bundle)[tobimori/kirby-queues

A comprehensive background job queue system for Kirby CMS with scheduled task support and panel monitoring interface

141.3k](/packages/tobimori-kirby-queues)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
