PHP code example of bnomei / kirby3-ics

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

    

bnomei / kirby3-ics example snippets


// automatic id
$ics = new \Bnomei\ICS();
$id = $ics->id();

// or use custom id
$id = sha1('myUniqueID');

// provide custom options
$ics = new \Bnomei\ICS([
    Vcalendar::UNIQUE_ID => $id,
]);

// maybe reuse a static object identified by id
// otherwise it will be created now
$ics = \Bnomei\ICS::createOrLoad($id);

// get Vcalendar object...
$vcalendar = $ics->vcalendar();
// ... apply your ics data (see docs of lib)
// then retrieve the ics string
echo $ics;

$vcalendar = $page->ics()->vcalendar();

$vcalendar->setXprop(Vcalendar::X_WR_CALDESC, "This is a demo calendar");

$event1 = $vcalendar->newVevent()
    ->setTransp( Vcalendar::OPAQUE )
    ->setClass( Vcalendar::P_BLIC )
    ->setSequence( 1 )
    // describe the event
    ->setSummary( 'Scheduled meeting with five occurrences' )
    ->setDescription(
         'Agenda for the the meeting...',
         [ Vcalendar::ALTREP => 
             'CID:<[email protected]>' ]
    )
    ->setComment( 'It\'s going to be fun..' )
    // place the event
    ->setLocation( 'Kafé Ekorren Stockholm' )
    ->setGeo( '59.32206', '18.12485' )
    // set the time
    ->setDtstart(
        new DateTime(
            '20190421T090000',
            new DateTimezone( 'Europe/Stockholm' )
        )
    )
    ->setDtend(
        new DateTime(
            '20190421T100000',
            new DateTimezone( 'Europe/Stockholm' )
        )
    );

echo $page->ics();

$page->ics()->download(
    $page->slug() . '.ics'
);