PHPackages                             adlogix/php-event-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. adlogix/php-event-scheduler

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

adlogix/php-event-scheduler
===========================

Solution in php to schedule recurring events based on Martin Fowlers paper

30PHP

Since May 24Pushed 7y ago3 watchersCompare

[ Source](https://github.com/adlogix/php-event-schedular)[ Packagist](https://packagist.org/packages/adlogix/php-event-scheduler)[ RSS](/packages/adlogix-php-event-scheduler/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Adlogix Event Scheduler
=======================

[](#adlogix-event-scheduler)

The Adlogix Event Scheduler library provides a way to manage recurring events using Martin Fowler's [Recurring Event pattern](http://martinfowler.com/apsupp/recurring.pdf). The base of the code and documentation was initially forked from [RiskioFr's solution](https://github.com/RiskioFr/EventScheduler) and completely refactored to be more lightweight and with less dependencies!

[![Build Status](https://camo.githubusercontent.com/6eadc07a31c281c17f596579bd4e5593b3cbae71f09ef37d1fa19d38ed35bdc3/68747470733a2f2f7472617669732d63692e6f72672f61646c6f6769782f7068702d6576656e742d7363686564756c61722e737667)](https://travis-ci.org/adlogix/php-event-schedular)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e27a656a857543ac2ebd5016dd632e160eee92f77f258c666610549ce3855943/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f61646c6f6769782f7068702d6576656e742d7363686564756c61722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/adlogix/php-event-schedular/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/bd5e357410c8c6119c5554e04daa2059891d33c18c03259dfac57ed3aaec9dbb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f61646c6f6769782f7068702d6576656e742d7363686564756c61722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/adlogix/php-event-schedular/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/c9ce9c2f2fe0910849d115ac75488133c43e857f7d9a8b88baaee0d624f1fde6/68747470733a2f2f706f7365722e707567782e6f72672f61646c6f6769782f7068702d6576656e742d7363686564756c65722f762f737461626c65)](https://packagist.org/packages/adlogix/php-event-scheduler)[![Total Downloads](https://camo.githubusercontent.com/05eb0bceb3698f1cf99d2b95fc7fca903682bd7b741e302544f2ec5a76247e14/68747470733a2f2f706f7365722e707567782e6f72672f61646c6f6769782f7068702d6576656e742d7363686564756c65722f646f776e6c6f616473)](https://packagist.org/packages/adlogix/php-event-scheduler)[![Latest Unstable Version](https://camo.githubusercontent.com/8b2699fabe615db3d0dfd745a538e3ae6bdb3940f3e25473a0188bb8de2e3698/68747470733a2f2f706f7365722e707567782e6f72672f61646c6f6769782f7068702d6576656e742d7363686564756c65722f762f756e737461626c65)](https://packagist.org/packages/adlogix/php-event-scheduler)[![License](https://camo.githubusercontent.com/c11617b4291c5a5e2d0dbb0832335ae25cfbe9764c01a0cd0d9ff1399a911067/68747470733a2f2f706f7365722e707567782e6f72672f61646c6f6769782f7068702d6576656e742d7363686564756c65722f6c6963656e7365)](https://packagist.org/packages/adlogix/php-event-scheduler)

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

[](#requirements)

- PHP 7.1 or higher

Documentation
-------------

[](#documentation)

The documentation will help you to understand how to use and extend Schedule.

### Introduction

[](#introduction)

The schedule represented by `Adlogix\EventScheduler\Scheduler` class allows you to know if any event occurs at a given date.

### Usage

[](#usage)

To start, you must instantiate `Adlogix\EventScheduler\Scheduler` and schedule some events using `Adlogix\EventScheduler\Scheduler::schedule` method.

This example schedule an event with `DayInMonth` temporal expression. So, the event will occur at 15th day of each coming months.

```
use Adlogix\EventScheduler\Scheduler;
use Adlogix\EventScheduler\TemporalExpression;

$scheduler = new Scheduler();
$scheduledEvent = $scheduler->schedule(new BasicEvent('event_name'), new TemporalExpression\DayInMonth(15));
```

If you want to cancel this event, you can provide the returned instance of `Adlogix\EventScheduler\SchedulableEvent` to the `Adlogix\EventScheduler\Scheduler::cancel` method.

```
$scheduler->cancel($scheduledEvent);
```

### Temporal Expressions

[](#temporal-expressions)

A temporal expression implements `Adlogix\EventScheduler\TemporalExpression\TemporalExpressionInterface` that provides useful `isOccurring` method to check if an event occur or not at a given date represented by an instance of `DateTimeInterface`.

```
$temporalExpression = new TemporalExpression();

$isOccuring = $temporalExpression->isOccuring(new BasicEvent('event_name'), $date);
```

#### Default temporal expressions

[](#default-temporal-expressions)

By default, there are some temporal expressions that you can use to define event recurrence.

##### EachDay

[](#eachday)

- class: Adlogix\\EventScheduler\\TemporalExpression\\EachDay

###### Example

[](#example)

```
use Adlogix\EventScheduler\TemporalExpression\EachDay;

$expression = new EachDay();
```

##### DayInWeek

[](#dayinweek)

- class: Adlogix\\EventScheduler\\TemporalExpression\\DayInWeek
- parameters: day (1-7)

###### Examples

[](#examples)

```
use Adlogix\EventScheduler\TemporalExpression\DayInWeek;
use Adlogix\EventScheduler\ValueObject\WeekDay;

$expression = new DayInWeek(WeekDay::MONDAY);

$expression = DayInWeek::monday();
```

##### DayInMonth

[](#dayinmonth)

- class: Adlogix\\EventScheduler\\TemporalExpression\\DayInMonth
- parameters: day (1-31)

###### Example

[](#example-1)

```
use Adlogix\EventScheduler\TemporalExpression\DayInMonth;

$expression = new DayInMonth(15);
```

##### WeekInYear

[](#weekinyear)

- class: Adlogix\\EventScheduler\\TemporalExpression\\WeekInYear
- parameters: month (1-12)

###### Example

[](#example-2)

```
use Adlogix\EventScheduler\TemporalExpression\WeekInYear;
use Adlogix\EventScheduler\ValueObject\Month;

$expression = new WeekInYear(15);
```

##### MonthInYear

[](#monthinyear)

- class: Adlogix\\EventScheduler\\TemporalExpression\\MonthInYear
- parameters: month (1-12)

###### Examples

[](#examples-1)

```
use Adlogix\EventScheduler\TemporalExpression\MonthInYear;
use Adlogix\EventScheduler\ValueObject\Month;

$expression = new MonthInYear(Month::JANUARY);

$expression = MonthInYear::january();
```

##### Semester

[](#semester)

- class: Adlogix\\EventScheduler\\TemporalExpression\\Semester
- parameters: semester (1-2)

###### Example

[](#example-3)

```
use Adlogix\EventScheduler\TemporalExpression\Semester;

$expression = new Semester(1);
```

##### Trimester

[](#trimester)

- class: Adlogix\\EventScheduler\\TemporalExpression\\Trimester
- parameters: trimester (1-4)

###### Example

[](#example-4)

```
use Adlogix\EventScheduler\TemporalExpression\Trimester;

$expression = new Trimester(1);
```

##### Year

[](#year)

- class: Adlogix\\EventScheduler\\TemporalExpression\\Year
- parameters: year

###### Example

[](#example-5)

```
use Adlogix\EventScheduler\TemporalExpression\Year;

$expression = new Year(2015);
```

##### LeapYear

[](#leapyear)

- class: Adlogix\\EventScheduler\\TemporalExpression\\LeapYear

###### Example

[](#example-6)

```
use Adlogix\EventScheduler\TemporalExpression\LeapYear;

$expression = new LeapYear();
```

##### From

[](#from)

- class: Adlogix\\EventScheduler\\TemporalExpression\\From
- parameters: `DateTimeInterface` instance

###### Example

[](#example-7)

```
use DateTime;
use Adlogix\EventScheduler\TemporalExpression\From;

$date = new DateTime();
$expression = new From($date);
```

##### Until

[](#until)

- class: Adlogix\\EventScheduler\\TemporalExpression\\Until
- parameters: `DateTimeInterface` instance

###### Example

[](#example-8)

```
use DateTime;
use Adlogix\EventScheduler\TemporalExpression\Until;

$date = new DateTime();
$expression = new Until($date);
```

##### RangeEachYear

[](#rangeeachyear)

- class: Adlogix\\EventScheduler\\TemporalExpression\\RangeEachYear
- parameters:
    - start month (1-12)
    - end month (1-12)
    - start day (1-31)
    - end day (1-31)

###### Examples

[](#examples-2)

```
use Adlogix\EventScheduler\TemporalExpression\RangeEachYear;

// From January to March inclusive
$expression = new RangeEachYear(1, 3);

// From January 10 to March 20
$expression = new RangeEachYear(1, 3, 10, 20);
```

#### Composite Temporal Expressions

[](#composite-temporal-expressions)

In order to create complex temporal expressions, you can use composite temporal expressions that allow to build combinaisons of previous ones.

##### Intersection

[](#intersection)

An event is occuring at a given date if it lies within all temporal expressions.

###### Example

[](#example-9)

```
use DateTime;
use Adlogix\EventScheduler\TemporalExpression\Collection\Intersection;
use Adlogix\EventScheduler\TemporalExpression\DayInMonth;
use Adlogix\EventScheduler\TemporalExpression\MonthInYear;

$intersection = new Intersection();
$intersection->addElement(new DayInMonth(15));
$intersection->addElement(MonthInYear::january());

$intersection->isOccuring('event', new DateTime('2015-01-15')); // returns true
$intersection->isOccuring('event', new DateTime('2015-01-16')); // returns false
$intersection->isOccuring('event', new DateTime('2015-02-15')); // returns false
```

##### Union

[](#union)

An event is occuring at a given date if it lies within at least one temporal expression.

###### Example

[](#example-10)

```
use DateTime;
use Adlogix\EventScheduler\TemporalExpression\Collection\Union;
use Adlogix\EventScheduler\TemporalExpression\DayInMonth;
use Adlogix\EventScheduler\TemporalExpression\MonthInYear;

$union = new Union();
$intersection->addElement(new DayInMonth(15));
$intersection->addElement(MonthInYear::january());

$intersection->isOccuring('event', new DateTime('2015-01-15')); // returns true
$intersection->isOccuring('event', new DateTime('2015-01-16')); // returns false
$intersection->isOccuring('event', new DateTime('2015-02-15')); // returns true
```

##### Difference

[](#difference)

An event is occuring at a given date if it lies within first temporal expression and not within the second one.

###### Example

[](#example-11)

```
use DateTime;
use Adlogix\EventScheduler\TemporalExpression\DayInMonth;
use Adlogix\EventScheduler\TemporalExpression\Difference;
use Adlogix\EventScheduler\TemporalExpression\MonthInYear;

$difference = new Difference(MonthInYear::january(), new DayInMonth(15));

$intersection->isOccuring('event', new DateTime('2015-01-15')); // returns false
$intersection->isOccuring('event', new DateTime('2015-01-16')); // returns true
$intersection->isOccuring('event', new DateTime('2015-02-15')); // returns false
```

#### Custom Temporal Expressions

[](#custom-temporal-expressions)

You can create temporal expressions that match your special needs by implementing `Adlogix\EventScheduler\TemporalExpression\TemporalExpressionInterface`.

### Cookbook

[](#cookbook)

After detailing the different temporal expressions available, consider a concrete case with complex temporal expression that could be used in real life.

In the example below, we include every Saturday and Sunday except on July and August.

```
use Adlogix\EventScheduler\TemporalExpression\Collection\Union;
use Adlogix\EventScheduler\TemporalExpression\DayInWeek;
use Adlogix\EventScheduler\TemporalExpression\Difference;
use Adlogix\EventScheduler\TemporalExpression\MonthInYear;

$includedWeekDays = new Union();
$union->addElement(DayInWeek::saturday());
$union->addElement(DayInWeek::sunday());

$excludedMonths = new Union();
$union->addElement(MonthInYear::july());
$union->addElement(MonthInYear::august());

$expression = new Difference($includedWeekDays, $excludedMonths);
```

###  Health Score

19

—

LowBetter than 12% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c680c4ee39ba02387677eb4803b18010c8a630db2737f8306d4732716426bb4?d=identicon)[toni.vdv](/maintainers/toni.vdv)

---

Top Contributors

[![tonivdv](https://avatars.githubusercontent.com/u/1267658?v=4)](https://github.com/tonivdv "tonivdv (7 commits)")

### Embed Badge

![Health badge](/badges/adlogix-php-event-scheduler/health.svg)

```
[![Health](https://phpackages.com/badges/adlogix-php-event-scheduler/health.svg)](https://phpackages.com/packages/adlogix-php-event-scheduler)
```

PHPackages © 2026

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