This package is abandoned and no longer maintained. The author suggests using the bomo/ical-bundle package instead.

Create ics url or file for Symfony 2

1.1.0 2016-04-26 15:24 UTC

This package is not auto-updated.

Last update: 2017-02-06 13:55:07 UTC



This bundle is based on work done by BOMO (https://github.com/BorisMorel/IcalBundle).

Update 06-02-2017:

This bundle was set up because we assumed the bundle by BOMO was abandoned. However, the Pull Request we proposed was merged eventually, so this bundle is no longer needed. Please don't use this bundle but use the BOMOIcalBundle.

This bundle is used to create an ics file or url to populate a shared calendar with events.


public function getIcs()
    $provider = $this->get('drenso_ical.ics_provider');

    $tz = $provider->createTimezone();
        ->setProperty('X-LIC-LOCATION', $tz->getTzid())

    $cal = $provider->createCalendar($tz);

        ->setName('My cal1')

    $datetime = new \Datetime('now');
    $event = $cal->newEvent();
        ->setEndDate($datetime->modify('+5 hours'))
        ->setName('Event 1')
        ->setDescription('Desc for event')
        ->setAttendee('John Doe')

    $alarm = $event->newAlarm();
        ->setTrigger('-PT2H') //See Dateinterval string format

    // All Day event
    $event = $cal->newEvent();
        ->setEndDate($datetime->modify('+10 days'))
        ->setName('All day event')
        ->setDescription('All day visualisation')

    $calStr = $cal->returnCalendar();

    return new Response(
            'Content-Type' => 'text/calendar; charset=utf-8',
            'Content-Disposition' => 'attachment; filename="calendar.ics"',


  • 2013/10/01 : first version
  • 2013/10/02 : Fixx issue #2
  • 2013/10/07 : Fix issue #1
  • 2016/03/21 : New release for Symfony 3.0 under Drenso ownership

Actual state

This bundle is in stable state;


Add DrensoIcalBundle in your composer.json

    "require": {
        "drenso/ical-bundle": "~1.0"

Now tell composer to download the bundle by running the step:

$ php composer.phar update drenso/ical-bundle


$bundles = array(
    new Drenso\IcalBundle\DrensoIcalBundle(),

User's Guide

All objects can be managed regardless by the provider. But the object need to be attached.

Event attached to Calendar

Alarm attached to Event

To simplify the use, the objects are a proxy method to create a child feature.

$alarm = $event->newAlarm();

Is stricly same that

$alarm = $provider->createAlarm();

Object reference


Timezone function createTimezone();
Calendar function createCalendar();
Event function createEvent();
Alarm function createAlarm();


Timezone function __construct(array $config=null);
string function getTzid();
this function setTzid($tz);
this function setProperty($name, $value);
vtimezone function getTimezone();


Calendar function __construct(array $config);
this function setName($name);
this function setDescription($desc);
Event function newEvent(); //Directly attached to this Calendar
this function attachEvent(Event $event)
string function returnCalendar();
vcalendar function getCalendar();


Event function __construct(mixed $param);
this function setStartDate(Datetime $date);
this function setEndDate(Datetime $date);
this function isAllDayEvent();
this function setName($name);
this function setLocation($loc);
this function setDescription($desc);
this function setComment($comment);
this function setAttendee($attendee);
this function setOrganizer($org);
Alarm function newAlarm(); //Directly attached to this Event
this function attachAlarm(Alarm $alarm);
mixed function getProperty($prop);
vevent function getEvent();


Alarm function __construct(mixed $param);
this function setAction($action); //Currently, only 'display' action is setted.
this function setDescription($desc);
this function setTrigger($trigger);
valarm function getAlarm();

Configuration example

Currently, this bundle doesn't required any configuration section.