chriskelemba / event-calendar
Pure PHP calendar event helpers for Google Calendar links and ICS invites.
v1.1.0
2026-04-21 11:54 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^10.5
README
Pure PHP helpers for scheduling an event and exporting it as:
- a Google Calendar link
- an
.icsfile for Apple Calendar, Outlook, Google Calendar imports, and similar apps
The package has no Laravel, Yii, Symfony, or framework dependency, so it can be used in raw PHP or inside any PHP framework.
Installation
composer require chriskelemba/event-calendar
If you are developing it locally first:
cd /Users/Chris/Desktop/event-calendar composer install composer test
Basic usage
<?php require __DIR__ . '/vendor/autoload.php'; use ChrisKelemba\EventCalendar\CalendarInvite; $invite = CalendarInvite::fromStrings( title: 'Project Kickoff', startAt: '2026-04-25 09:00:00', endAt: '2026-04-25 10:00:00', description: 'Initial planning session with the team', location: 'Nairobi Office', timezone: 'Africa/Nairobi', ); $googleLink = $invite->googleLink(); $icsContent = $invite->ics(); file_put_contents(__DIR__ . '/kickoff.ics', $icsContent); echo $googleLink;
Raw PHP download example
<?php use ChrisKelemba\EventCalendar\CalendarEvent; use ChrisKelemba\EventCalendar\IcsGenerator; $event = CalendarEvent::fromStrings( 'Board Meeting', '2026-04-30 14:00:00', '2026-04-30 15:00:00', 'Quarterly business review', 'Conference Room', 'Africa/Nairobi' ); $ics = (new IcsGenerator())->generate($event); header('Content-Type: text/calendar; charset=UTF-8; method=REQUEST'); header('Content-Disposition: attachment; filename="board-meeting.ics"'); echo $ics;
Laravel / Yii / other frameworks
Create the invite directly from request, DTO, model, or form data:
- use
GoogleCalendarLinkGeneratorif you only need a redirect URL - use
IcsGeneratorif you want to attach or download an.icsfile - use
CalendarInviteif you want both
Example flow:
use ChrisKelemba\EventCalendar\CalendarInvite; $invite = CalendarInvite::fromStrings( $data['title'], $data['start_at'], $data['end_at'], $data['description'] ?? null, $data['location'] ?? null, $data['timezone'] ?? 'UTC', ); $googleLink = $invite->googleLink(); $icsContent = $invite->ics();
Package structure
CalendarEvent: immutable event data object with validationGoogleCalendarLinkGenerator: builds Google Calendar template URLsIcsGenerator: creates RFC-5545 style calendar contentCalendarInvite: tiny convenience wrapper that can build the event and generate both outputs