- How do I install rlanvin/php-rrule in a Laravel application?
- Run composer require rlanvin/php-rrule from your project root; the package requires PHP 7.3 or newer and has no other hard dependencies. There is no service provider, facade, or config file to publish because the library is framework-agnostic and touches nothing in the Laravel container. Just import RRule or RSet in your class and Composer autoloading handles the rest. If you want human-readable descriptions, install the intl extension, which is recommended but optional.
- Is rlanvin/php-rrule compatible with Laravel 8, 10, 11 and 12?
- Yes. Every currently supported Laravel release requires a PHP version that already satisfies the library's PHP 7.3 floor, so there is no version conflict. The package is a plain PHP dependency with no Laravel coupling, meaning upgrades of either side cannot break the other. You can drop it into Laravel 8 through 12 without a compatibility shim.
- How do I calculate recurring dates or events with RRULE in PHP?
- Build an RRule instance from an array of rule parts such as FREQ, INTERVAL, DTSTART and COUNT, then loop over it or call getOccurrences(). Each occurrence is a DateTime object you can format, compare, or persist. For bounded windows use getOccurrencesBetween() with explicit start and end dates instead of iterating the whole rule. The same object works inside a Laravel job, command, API resource, or notification scheduler.
- Does php-rrule handle timezones and daylight saving time correctly?
- The library accepts a timezone on DTSTART or via TZID in the rule string and returns occurrences in that zone, but DST handling has historically been its most defect-prone area. Past releases fixed DST issues on PHP 8.1, Exchange/M365 timezone handling, Windows timezone names, and offset-style timezones. For a rule like 9am every weekday, add explicit tests that cross your DST boundaries so you catch the 9am-becomes-10am or double-fire cases before users do.
- How do I write unit tests for recurring date logic in Laravel?
- Because the library is a pure function of rule string, DTSTART and timezone, you can test it in a plain PHPUnit test with no database, container, or HTTP layer involved. Use fixed DTSTART values, assert the first N occurrences and their formatting, and add cases for month-end dates, leap years, and DST transitions. If your application code wraps the library, test the wrapper's limit and exception handling too, since that is where denial-of-service and malformed-rule bugs live.
- How do I prevent an infinite loop when a recurrence rule has no COUNT or UNTIL?
- A rule with FREQ but no COUNT or UNTIL is infinite, so an unguarded foreach or getOccurrences() call will exhaust CPU and memory. Always pass an explicit limit to getOccurrences(), or use getOccurrencesBetween() with a bounded window such as a 6-week calendar grid or a 12-month agenda. Never call the constructor or iterate an unbounded rule directly in a request path without a cap and a timeout. Treat the maximum expansion window as a product decision, not an implementation detail.
- Can I parse RRULE strings from Google Calendar, Outlook or ICS feeds?
- You can use RRule::createFromRfcString() or RSet to parse standard RFC 5545 strings, but the library is deliberately strict and rejects non-compliant rule parts that real-world exporters often produce. Any import path needs a tolerant sanitizing layer plus try/catch around parsing, never an unguarded constructor call in a controller. Decide up front whether you only author your own rules or must round-trip third-party strings, because that requirement changes the design of the import pipeline.
- How do I combine RRULE with EXDATE, RDATE and EXRULE exceptions?
- Use the RSet class, which composes one or more RRULEs with RDATE inclusions, EXDATE exclusions and EXRULE rules exactly as a VEVENT would. RSet implements the same iteration interface as RRule, so you can swap it in without changing your loops. This is the right tool for calendar-style data where users add exceptions such as cancelled meetings or moved sessions.
- How do I generate human-readable descriptions of a recurrence rule?
- Call humanReadable() on the RRule instance to get output such as monthly on the 1st of the month, starting from 01/06/2015, 6 times. The intl extension is recommended for this feature but not required, so check whether localized descriptions are in your v1 scope before making intl a hard platform requirement. The package ships translations and a bin/review_translations.php script for reviewing output in each locale.
- Is rlanvin/php-rrule actively maintained, and what are the alternatives?
- The project is MIT licensed according to its README, has a real changelog through version 2.6.0, and is used widely, but it is maintained by a single developer with no commercial backing or SLA. Packagist currently shows the license as NOASSERTION, which is almost certainly registry metadata hygiene but should be confirmed with legal before shipping commercially. Pin a specific version rather than floating, verify the tag exists, and treat a fork as an acceptable fallback since the codebase is small. Alternatives include sabre/vobject's RRuleIterator and simshaun/recurr, both of which also implement RFC 5545 expansion.