My Blog Posts

library of iCalendars for PHP

library of iCalendars for PHP


use Eluceo\Ical\Component\Calendar;
use Eluceo\Ical\Component\Event;

$vCalendar = new Calendar('www.example.com');
$vCalendar->setName('Example Calendar');
$vCalendar->setTimezone('America/New_York');

$vEvent = new Event();
$vEvent
    ->setDtStart(new \DateTime('2012-12-24'))
    ->setDtEnd(new \DateTime('2012-12-24'))
    ->setNoTime(True)
    ->setSummary('Christmas');

$vCalendar->addComponent($vEvent);

header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="cal.ics"');

Echo $vCalendar->render();

The library supports the following iCalendar components:

  • VCALENDAR
  • VEVENT
  • VALARM
  • VTIMEZONE

Example of connecting to a calendar after you add it to your app:

<  a href="webcal://www.example.com/holidays.ics">Subscribe(iCal)a> 

Markuspoerschke / iCal learn more about this package on GitHub, get all setup instructions, and view the source code .



Share this article


Comments (0)

Comment