PHP Class to generate VCalendar (ics) file

1.0.2 2018-06-17 09:10 UTC

This package is auto-updated.

Last update: 2021-09-13 14:59:39 UTC


PHP Class to generate VCalendar (ics) file. Compatible with GMail Calendar attachement.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License composer.lock available Code Climate Test Coverage Issue Count


This page contains information about installing the Library for PHP.


  • PHP version 5.4.0 or greater (including PHP 7)

Obtaining the client library

There are two options for obtaining the files for the client library.

Using Composer

You can install the library by adding it as a dependency to your composer.json.

  "require": {
    "davaxi/vcalendar": "^1.0"

Cloning from GitHub

The library is available on GitHub. You can clone it into a local repository with the git clone command.

git clone https://github.com/davaxi/VCalendar.git

What to do with the files

After obtaining the files, ensure they are available to your code. If you're using Composer, this is handled for you automatically. If not, you will need to add the autoload.php file inside the client library.

require '/path/to/vcalendar/folder/autoload.php';



require '/path/to/vcalendar/folder/autoload.php';

$VCalendar = new Davaxi\VCalendar();
$VCalendar->setProcess('Davaxi', 'Davaxi Events', 'v1.0', 'EN');
$VCalendar->setCalendarName('Events - Davaxi');
$VCalendar->setStartDateTime('2016-06-10 10:00:00');
$VCalendar->setEndDateTime('2016-06-10 14:00:00');
$VCalendar->setTitle('My Event Title');
$VCalendar->setDescription('My Event Description');
$VCalendar->setOrganizer('Davaxi', 'root@domain.fr');
$VCalendar->setCreatedDateTime('2016-06-01 00:00:00');
$VCalendar->setLocation('Paris', 48.874086, 2.345640);
$VCalendar->setLastUpdatedDateTime('2016-06-01 01:00:00');
$VCalendar->addAttendee('Guest', 'REQ-PARTICIPANT', 'guest@domain.com',false);


// Filename for download stream
$event = new Davaxi\VCalendar($fileName = 'invite');

// Set process info
$VCalendar->setProcess($processOwner, $processName, $processVersion, $processLang)

// Set method (REQUEST / PUBLISH)

// Set event calendar name

// Set event timezone

// If Event on all day

// Set event start datetime

// Set event end datetime

// Set event status (TENTATIVE / CONFIRMED / CANCELED) 

// Set event title

// Set event description

// Set organize info
$VCalendar->setOrganizer($organizerName, $organizerEmail);

// Set event class (PUBLIC / PRIVATE / CONFIDENTIAL)

// Set event created datetime

// Set event location 
$VCalendar->setLocation($locationString, $locationLat, $locationLng);

// Set event URL

// Set sequence

// Set event last updated datetime

// Set event categories

// Set event UID (for updates)

$VCalendar->addAttendee($name, $type, $email, $rsvp);

// Stream file with header
// or get content
$content = $VCalendar->getContent();

Integrate with PHPMailer with GMail direct add to calendar action

$PHPMailer = new PHPMailer();
$VCalendar = new Davaxi\VCalendar();
// [...] Set VCalendar
// [...] Configure PHPMailer