PHPackages                             bobv/ical - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bobv/ical

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bobv/ical
=========

The eluceo/iCal package offers an abstraction layer for creating iCalendars. You can easily create iCal files by using PHP objects instead of typing your \*.ics file by hand. The output will follow RFC 5545 as best as possible.

2.16.0(4mo ago)0774↓44.7%MITPHPPHP &gt;=8.3CI failing

Since Mar 2Pushed 4mo agoCompare

[ Source](https://github.com/bobvandevijver/iCal)[ Packagist](https://packagist.org/packages/bobv/ical)[ Docs](https://github.com/markuspoerschke/iCal)[ RSS](/packages/bobv-ical/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (67)Used By (0)

📅 eluceo — iCal 2
=================

[](#-eluceo--ical-2)

[![Continuous Integration](https://github.com/markuspoerschke/iCal/actions/workflows/ci.yml/badge.svg)](https://github.com/markuspoerschke/iCal/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/54499bdc4e8ac091e416bcf50f811f495f078f3ef3b233ec601b763fa5063944/68747470733a2f2f636f6465636f762e696f2f67682f6d61726b7573706f65727363686b652f6943616c2f6272616e63682f322e782f67726170682f62616467652e737667)](https://codecov.io/gh/markuspoerschke/iCal)[![Psalm coverage](https://camo.githubusercontent.com/240aabb4ea09916a96af5e74e5841bf17112a6adbf6a9efa3e896647b98f8b00/68747470733a2f2f73686570686572642e6465762f6769746875622f6d61726b7573706f65727363686b652f6963616c2f636f7665726167652e7376673f)](https://shepherd.dev/github/markuspoerschke/ical)[![License](https://camo.githubusercontent.com/a969880f760d28cb3309f9ad6c51a3fb7265ad7207c0d99a4fa9a6d32073add9/68747470733a2f2f706f7365722e707567782e6f72672f656c7563656f2f6963616c2f6c6963656e7365)](https://packagist.org/packages/eluceo/ical)[![Latest Stable Version](https://camo.githubusercontent.com/48c617b68bed52f4f0c2ec6a98c816a123c896271c93cfcfb39397aba0d3b402/68747470733a2f2f706f7365722e707567782e6f72672f656c7563656f2f6963616c2f762f737461626c65)](https://packagist.org/packages/eluceo/ical)[![Monthly Downloads](https://camo.githubusercontent.com/6ce9bdabf783eeff2689e1b94cb6c878c7c8c95ae94149d918dcc52e454b0d41/68747470733a2f2f706f7365722e707567782e6f72672f656c7563656f2f6963616c2f642f6d6f6e74686c79)](https://packagist.org/packages/eluceo/ical)[![Infection MSI](https://camo.githubusercontent.com/df9336af81d18762149fcb7c3e879cf64972d047c3ec4e5b682d98c4e464d8e6/68747470733a2f2f62616467652e737472796b65722d6d757461746f722e696f2f6769746875622e636f6d2f6d61726b7573706f65727363686b652f6943616c2f322e78)](https://infection.github.io)

This package offers an abstraction layer for creating iCalendars files. By using this PHP package, you can create `*.ics` files without the knowledge of the underling format. The output itself will follow [RFC 5545](https://www.ietf.org/rfc/rfc5545.html) as good as possible.

Navigate through the project
----------------------------

[](#navigate-through-the-project)

- 📖 [read the documentation](https://ical.poerschke.nrw)
- 🐛 [report a bug or suggest a feature](https://github.com/markuspoerschke/iCal/issues)
- 🙋 [raise a question](https://github.com/markuspoerschke/iCal/discussions/categories/q-a)
- 💬 [start a discussion](https://github.com/markuspoerschke/iCal/discussions)

Installation
------------

[](#installation)

You can install this package by using [Composer](http://getcomposer.org), running the following command:

```
composer require eluceo/ical
```

Version / Upgrade
-----------------

[](#version--upgrade)

The initial version was released back in 2012. The version 2 of this package is a complete rewrite of the package and is not compatible to older version. Please see the upgrade guide if you want to migrate from version `0.*` to `2.*`. If you just start using this package, you should install version 2.

VersionPHP Version&gt;= 2.15&gt;=8.3&lt; 2.147.4 - 8.30.16.\*7.0 - 8.20.11.\*5.3.0 - 7.4Documentation
-------------

[](#documentation)

Visit [ical.poerschke.nrw](https://ical.poerschke.nrw/) for complete documentation.

Usage
-----

[](#usage)

The classes within this package are grouped into two namespaces:

- The `Domain` contains the information about the events.
- The `Presentation` contains the transformation from `Domain` into a `*.ics` file.

To create a calendar, the first step will be to create the corresponding domain objects. Then these objects can be transformed into a iCalendar PHP representation, which can be cast to string.

### Empty event

[](#empty-event)

In this very basic example, that renders an empty event. You will learn how to create an event domain object, how to add it to a calendar and how to transform it to a iCalendar component.

#### 1. Create an event domain entity

[](#1-create-an-event-domain-entity)

```
$event = new \Eluceo\iCal\Domain\Entity\Event();
```

#### 2. Create a calendar domain entity

[](#2-create-a-calendar-domain-entity)

```
$calendar = new \Eluceo\iCal\Domain\Entity\Calendar([$event]);
```

#### 3. Transform calendar domain object into a presentation object

[](#3-transform-calendar-domain-object-into-a-presentation-object)

```
$iCalendarComponent = (new \Eluceo\iCal\Presentation\Factory\CalendarFactory())->createCalendar($calendar);
```

#### 4. a) Save to file

[](#4-a-save-to-file)

```
file_put_contents('calendar.ics', (string) $iCalendarComponent);
```

#### 4. b) Send via HTTP

[](#4-b-send-via-http)

```
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="cal.ics"');

echo $iCalendarComponent;
```

### Full example

[](#full-example)

The following example will create a single day event with a summary and a description. More examples can be found in the [examples/](examples) folder.

```
