Due to a new feature development for the Joomla Extension Easy GCalendar we have created the iCal PHP Library. The Code is distributed under the MIT license and work also stand alone.
Installation
The Codeninja iCal library is available via GitHub download only.
Introduction
This library offers a abstraction layer for creating iCal Calendars and .ics files. The output will be generated according RFC 5545.
The following types are currently supported and could be used in combination:
- VCALENDAR
- VEVENT
Basic Usage
Create a Calendar object
$calendar = new \Codeninja\iCal\Calendar('www.example-site.com');
Create a new Event object
$myEvent = new \Codeninja\iCal\Event();
Add required and optional information to the Event object
$myEvent->setDtStart(new \DateTime()); $myEvent->setDtEnd(new \DateTime()); $myEvent->setisAllDay(true); $myEvent->setSummary('Summary: Lorem Ipsum'); $myEvent->setDescription('Lorem Ipsum is simply dummy text of the printing industry.');
Add event to calendar object
$calendar->addEvent($myEvent);
Generate & display output
$content = $calendar->render(); echo $content;
And that’s it, have fun!