News

iCal Library for PHP

Published
iCal Library for PHP image

Markus Poerschke has PHP package that provides an abstraction layer for creating iCalendars:

use Eluceo\iCal\Component\Calendar;
use Eluceo\iCal\Component\Event;
 
$vCalendar = new Calendar('www.example.com');
$vCalendar->setName('Example Calendar');
$vCalendar->setTimezone('America/New_York');
 
$vEvent = new Event();
$vEvent
->setDtStart(new \DateTime('2012-12-24'))
->setDtEnd(new \DateTime('2012-12-24'))
->setNoTime(true)
->setSummary('Christmas');
 
$vCalendar->addComponent($vEvent);
 
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="cal.ics"');
 
echo $vCalendar->render();

The library supports the following iCalendar components:

  • VCALENDAR
  • VEVENT
  • VALARM
  • VTIMEZONE

After incorporating it in your application, here’s an example of linking to a calendar:

<a href="webcal://www.example.com/holidays.ics">Subscribe (iCal)</a>

You can learn more about this package, get full installation instructions, and view the source code on GitHub at markuspoerschke/iCal.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Filed in

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
Look What You Helped Me Build image

Look What You Helped Me Build

Read article
BashBox: A Sandboxed Bash Interpreter for AI Agents in PHP image

BashBox: A Sandboxed Bash Interpreter for AI Agents in PHP

Read article
Running Laravel's Scheduler on Multiple Servers image

Running Laravel's Scheduler on Multiple Servers

Read article
Laravel Fake Assertions Now Accept Property Arrays image

Laravel Fake Assertions Now Accept Property Arrays

Read article
Route::query() and Model defaults() in Laravel 13.35 image

Route::query() and Model defaults() in Laravel 13.35

Read article
Laravel AI SDK 1.1 Adds Agent Skills and Cohere Chat image

Laravel AI SDK 1.1 Adds Agent Skills and Cohere Chat

Read article