Skip to content

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

License

Notifications You must be signed in to change notification settings

maxwellmandela/php-recurrence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages