PHP library for working with recurrence rules, uses simshaun/recurr
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
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
Configure your script for php-recurrence
use Reccurence\Schedule;
$timezone = 'Africa/Nairobi';
$schedule = new Schedule($timezone);
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',
]);
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,
]);
All is welcome!