PHP code example of bomo / ical-bundle

1. Go to this page and download the library: Download bomo/ical-bundle 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/ */

    

bomo / ical-bundle example snippets



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

    $tz = $provider->createTimezone();
    $tz
        ->setTzid('Europe/Paris')
        ->setXProp('X-LIC-LOCATION', $tz->getTzid())
        ;

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

    $cal
        ->setName('My cal1')
        ->setDescription('Foo')
        ;

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

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

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

    $calStr = $cal->returnCalendar();

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

$alarm = $event->newAlarm();
$alarm
    ->set[...]
    [...]
    ;

$alarm = $provider->createAlarm();
$alarm
    ->set[...]
    [...]
    ;
$event->attachAlarm($alarm);

$ical = $cal = $this->provider->createCalendar(null, true);

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);
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);
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();
 bash
$ php composer.phar update bomo/ical-bundle
 php
$bundles = array(
    ...
    new BOMO\IcalBundle\BOMOIcalBundle(),
);