1. Go to this page and download the library: Download jsvrcek/ics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jsvrcek / ics example snippets
use Jsvrcek\ICS\Model\Calendar;
use Jsvrcek\ICS\Model\CalendarEvent;
use Jsvrcek\ICS\Model\Relationship\Attendee;
use Jsvrcek\ICS\Model\Relationship\Organizer;
use Jsvrcek\ICS\Utility\Formatter;
use Jsvrcek\ICS\CalendarStream;
use Jsvrcek\ICS\CalendarExport;
//setup an event
$eventOne = new CalendarEvent();
$eventOne->setStart(new \DateTime())
->setSummary('Family reunion')
->setUid('event-uid');
//add an Attendee
$attendee = new Attendee(new Formatter());
$attendee->setValue('[email protected]')
->setName('Moe Smith');
$eventOne->addAttendee($attendee);
//set the Organizer
$organizer = new Organizer(new Formatter());
$organizer->setValue('[email protected]')
->setName('Heidi Merkell')
->setLanguage('de');
$eventOne->setOrganizer($organizer);
//new event
$eventTwo = new CalendarEvent();
$eventTwo->setStart(new \DateTime())
->setSummary('Dentist Appointment')
->setUid('event-uid');
//setup calendar
$calendar = new Calendar();
$calendar->setProdId('-//My Company//Cool Calendar App//EN')
->addEvent($eventOne)
->addEvent($eventTwo);
//setup exporter
$calendarExport = new CalendarExport(new CalendarStream, new Formatter());
$calendarExport->addCalendar($calendar);
//output .ics formatted text
echo $calendarExport->getStream();
use Jsvrcek\ICS\Model\Calendar;
use Jsvrcek\ICS\Model\CalendarEvent;
use Jsvrcek\ICS\Utility\Formatter;
use Jsvrcek\ICS\CalendarStream;
use Jsvrcek\ICS\CalendarExport;
//setup calendar
$calendar = new Calendar();
$calendar->setProdId('-//My Company//Cool Calendar App//EN');
//setup event provider to add events in batches during event iteration in $calendarExport->getStream()
$calendar->setEventsProvider(function ($startKey) use ($myDatabase) {
//pseudo-code to get a batch of events from database
$eventDataArray = $myDatabase->getEventsBatch($startKey);
$events = array();
foreach ($eventDataArray as $row) {
$event = new CalendarEvent();
$event->setStart($row['start_date'])
->setSummary($row['summary'])
->setUid($row['event_uid']);
$events[] = $event;
}
return $events;
});
//setup exporter
$calendarExport = new CalendarExport(new CalendarStream, new Formatter());
$calendarExport->addCalendar($calendar);
//set exporter to send items directly to output instead of storing in memory
$calendarExport->getStreamObject()->setDoImmediateOutput(true);
//output .ics formatted text
echo $calendarExport->getStream();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.