PHP code example of xp-forge / ical

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

    

xp-forge / ical example snippets


use text\ical\ICalendar;
use util\cmd\Console;
use io\File;

$ical= new ICalendar();

$calendar= $ical->read('BEGIN:VCALENDAR...');
$calendar= $ical->read(Console::$in->stream());
$calendar= $ical->read(new File('meeting.ics'));

$ical->write($calendar, Console::$out->stream());
$ical->write($calendar, new File('meeting.ics'));

$event= $calendar->events()->first();

$events= $calendar->events(); 
if ($events->present()) {
  $event= $events->first();
} else {
  // Handle situation when no events are inside calendar
}

foreach ($calendar->events() as $event) {
  // ...
}

use text\ical\{
  Calendar,
  Event,
  Organizer,
  Attendee,
  IDate,
  Text,
  Method,
  Role,
  PartStat
};

$calendar= Calendar::with()
  ->method(Method::REQUEST)
  ->prodid('Microsoft Exchange Server 2010')
  ->version('2.0')
  ->events([Event::with()
    ->organizer(new Organizer('The Organizer', 'MAILTO:[email protected]'))
    ->attendees([
      Attendee::with()
        ->role(Role::CHAIR)
        ->partstat(PartStat::NEEDS_ACTION)
        ->rsvp('TRUE')
        ->cn('The Attendee 1')
        ->value('MAILTO:[email protected]')
        ->create()
      ,
      Attendee::with()
        ->role(Role::REQ_PARTICIPANT)
        ->partstat(PartStat::NEEDS_ACTION)
        ->rsvp('TRUE')
        ->cn('The Attendee 2')
        ->value('MAILTO:[email protected]')
        ->create()
    ])
    ->dtstart(new IDate(null, '20160524T183000Z'))
    ->dtend(new IDate(null, '20160524T190000Z'))
    ->location(new Text('de-DE', 'BS 50 EG 0102'))
    ->summary(new Text('de-DE', 'Treffen'))
    ->create()
  ])
  ->create()
;