PHP code example of phil / calendar-sync

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

    

phil / calendar-sync example snippets


use Phil\CalendarSync\Adapter\CalDav;
use Phil\CalendarSync\Adapter\GoogleCalendar;
use Phil\CalendarSync\Adapter\IcsFeed;
use Phil\CalendarSync\Adapter\MicrosoftGraph;
use Phil\CalendarSync\CalendarSync;
use Phil\CalendarSync\SyncWindow;

$writers = [new CalDav(), new GoogleCalendar(), new MicrosoftGraph()];
$sync = new CalendarSync($connections, $credentials, $busyStore, sources: [new IcsFeed(), ...$writers], destinations: $writers);

// The next 60 days of a member's calendar, joined into the fewest periods and given to the store.
$sync->refreshBusy($connectionId, SyncWindow::days(new DateTimeImmutable('today'), 60));

// A booking written into it, then withdrawn.
$sync->publish($connectionId, $booking);
$sync->withdraw($connectionId, $booking->uid);