maxwellmandela/php-recurrence

There is no license information available for the latest version (v0.9.1) of this package.

PHP library for working with recurrence rules, uses simshaun/recurr

v0.9.1 2019-07-07 15:02 UTC

This package is auto-updated.

Last update: 2024-03-29 04:19:15 UTC


README

68747470733a2f2f696d6167652e666c617469636f6e2e636f6d2f69636f6e732f7376672f3132332f3132333339322e737667

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

php-recurrence - A PHP Recurring events library

PHP library for working with recurrence rules, uses simshaun/recurr

What it does

Very simply, php-recurrence enables scheduling recurring events much like simshaun/recurr but with more abtraction, e.g twice every 3 weeks This will generate an event recurring two times every 3 weeks It also needs to be mentioned that this is an approach to learning to TDD in PHP

How to

Install

Install using Composer:

composer require maxwellmandela/php-recurrence

No composer? You can clone/download the repository and use the package directly by including bootstrap.php onto your script

Seting up

Configure your script for php-recurrence

use Reccurence\Schedule;

$timezone    = 'Africa/Nairobi';
$schedule = new Schedule($timezone);

Creating a simple weekly frequency

You can create a simple array of dates by passing the start,end,freq,interval this way

$events = $schedule->createEvents([
    'start' => '2019-07-01 00:00:00',
    'end'   => '2019-07-31 00:00:00',
    'interval' => 2,

    // for weekly events, you can change this to either  MONTHLY|YEARLY|DAILY|HOURLY
    // read more here: https://tools.ietf.org/html/rfc5545 for all valid frequencies
    'freq' => 'WEEKLY',
]);

Creating a weekly frequency with no. of times per interval

You can create an array of dates and number of recurrence per interval by passing the start,end,freq,interval,recurrence_count this way

$events = $schedule->createEvents([
    'start' => '2019-07-01 00:00:00',
    'end'   => '2019-07-31 00:00:00',
    'interval' => 2,
    'freq' => 'WEEKLY',

    // for an event recurring 3 times(recurrence_count) every(interval)  2 weeks(freq)
    'recurrence_count' => 3,
]);

Credits

simshaun/recurr
nesbot/carbon

Contribution

All is welcome!