sabre/vobject
Parse, generate, and manipulate iCalendar (RFC5545) and vCard (RFC6350) data in PHP with an easy-to-use API. sabre/vobject supports reading/writing VObject structures for calendar and contact workflows via Composer install.
Install via Composer:
composer require sabre/vobject "^4.0"
Ensure PHP ≥7.4 (latest releases support up to PHP 8.4). The library is fully namespaced under Sabre\VObject.
First use case: Parse a .vcf contact file or .ics calendar export:
use Sabre\VObject\Reader;
$vcard = Reader::read(file_get_contents('contact.vcf'));
echo $vcard->FN->getValue(); // Output contact name
$calendar = Reader::read(file_get_contents('events.ics'));
foreach ($calendar->VEVENT as $event) {
printf("%s: %s\n", $event->DTSTART->getValue(), $event->SUMMARY);
}
Review the vCard and iCalendar docs for detailed patterns.
Reader::read() (accepts strings, streams, or filenames) to parse ICS/VCF sources, then $component->serialize() to generate RFC-compliant output for download or storage.createComponent() and attach recurrence rules:
$event = $calendar->createComponent('VEVENT');
$event->set('SUMMARY', 'Team Sync');
$event->DTSTART = new DateTime('2025-06-02 09:00:00');
$event->RRULE = 'FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR';
$calendar->add($event);
ITip\Broker to auto-generate scheduling messages (REQUEST, CANCEL, REPLY) when events change. Detect significant changes and trigger notifications without manual SMTP code.RRuleIterator to render future instances for calendars or reminders:
$iterator = new RRuleIterator($event->RRULE, $event->DTSTART->getDateTime());
foreach ($iterator->getOccurrencesBetween($start, $end) as $occurrence) {
// Render or process each instance
}
Reader::read($data, Reader::OPTION_IGNORE_INVALID_LINES | Reader::OPTION_FORGIVING) to safely parse malformed but recoverable inputs (e.g., from legacy clients).DTSTART/DTEND use the correct value type (e.g., DATE-TIME with TZID or Z). Use Broker to generate correct timezones in iTip messages.InvalidDataException since v4.5.6. Validate rules before setting them (e.g., via Rrule::validate() if using custom rules).item1.FN, item1.EMAIL) are preserved or stripped consistently—use getProperty('item1.FN') or rely on select() when groups are unknown..ics files if you only need a date range; manually parse and skip irrelevant components. Reader::read() is forgiving but may be slower than Document::parse() for known-good data.Component or Property classes to add custom properties (e.g., X-CUSTOM-REF), and use VObject\NodeList to iterate non-standard fields.null where scalar types are expected. Many methods now declare strict return types (e.g., xmlSerialize(): void). Upgrade to v4.5.6+ for full PHP 8.4 support.How can I help you explore Laravel packages today?