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

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
pgjumbo: A PostgreSQL Client for macOS, Windows, and Linux image

pgjumbo: A PostgreSQL Client for macOS, Windows, and Linux

Read article
Laranon: Reversible PII Anonymization for Laravel and LLMs image

Laranon: Reversible PII Anonymization for Laravel and LLMs

Read article
PHP 8.6 is released!  image

PHP 8.6 is released!

Read article
Laravel Warrant: Row-Level Permissions With Eloquent image

Laravel Warrant: Row-Level Permissions With Eloquent

Read article
JSON Schema Validation Rules and a RetryFor Attribute in Laravel 13.43 image

JSON Schema Validation Rules and a RetryFor Attribute in Laravel 13.43

Read article
Durable Workflow: Long-Running Workflows for Laravel image

Durable Workflow: Long-Running Workflows for Laravel

Read article