Recurr

Recurr stats

Downloads
10.6M
Stars
1,265
Open Issues
50
Forks
138

View on GitHub →

PHP library for working with recurrence rules

Recurr - PHP Library for Recurrence Rules

Recurr is a versatile PHP library designed for crafting and managing recurrence rules (RRULE) based on the iCalendar (RFC5545) specification. It converts these rules into DateTime objects, making it an excellent tool for developers working with calendar-related applications.

Key Features

  • RRULE Creation: Easily create RRULE objects using either direct string input or a programmable interface that allows for flexible rule construction.
  • DateTime Conversion: Transform RRULEs into DateTime objects, providing an array of start and end DateTime pairs.
  • Constraints and Filters: Apply constraints to limit the recurrences generated and use filters on the RecurrenceCollection to refine the output based on dates.
  • Human-Readable Output: Convert RRULEs into a textual description (beta) to improve readability and understanding.
  • Configurable Behavior: Modify default behaviors, such as handling dates that fall on the last days of a month, to fit specific requirements.
  • Extensibility: The library is open for contributions and further development, encouraging improvements and additional features.

Installation

Recurr can be easily installed via Composer:

composer require simshaun/recurr

Usage Examples

Creating and Using Rules

// Create a rule
$rule = new \Recurr\Rule('FREQ=DAILY;COUNT=5', new \DateTime('today'), null, 'America/New_York');
 
// Transform rule to DateTime objects
$transformer = new \Recurr\Transformer\ArrayTransformer();
print_r($transformer->transform($rule));

Applying Constraints

// Apply a BeforeConstraint
$constraint = new \Recurr\Transformer\Constraint\BeforeConstraint(new \DateTime('tomorrow'));
print_r($transformer->transform($rule, $constraint));

Generating Human-Readable Text

// Convert RRULE to text
$textTransformer = new TextTransformer();
echo $textTransformer->transform($rule);

Handling Special Date Cases

// Adjust settings for end-of-month scenarios
$transformerConfig = new \Recurr\Transformer\ArrayTransformerConfig();
$transformerConfig->enableLastDayOfMonthFix();
$transformer->setConfig($transformerConfig);

Contributions

Developers are encouraged to contribute to the library by proposing features, submitting issues, and creating pull requests. Please ensure to include tests with PRs to maintain quality.

Recurr is a robust tool for managing recurring events in PHP applications, providing developers with the functionality needed to manipulate and display complex recurrence patterns efficiently.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Simshaun Recurr Related Articles

Model-Based Scheduling for Laravel with Cadence image

Model-Based Scheduling for Laravel with Cadence

Read article
Recurr is a PHP library for working with recurrence rules for calendar dates image

Recurr is a PHP library for working with recurrence rules for calendar dates

Read article
Securing Laravel logo

Securing Laravel

The essential security resource for Laravel devs, covering everything you need to keep your apps secure. Sign up to receive weekly security tips and monthly in depth articles, diving deep into security concepts you need to know!

Securing Laravel
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
DreamzTech logo

DreamzTech

Hire 6-10+ Yrs. experienced skilled Laravel Developers from DreamzTech. We ensure NDA protected, 100% quality delivery. Contact Us & Discuss Your Need.

DreamzTech
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm