PHPackages                             beastbytes/icalendar - 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. beastbytes/icalendar

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

beastbytes/icalendar
====================

Create, edit, and import iCalendar

v1.0.0(3y ago)045BSD-3-ClausePHPPHP ^8.0

Since Jun 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/beastbytes/icalendar)[ Packagist](https://packagist.org/packages/beastbytes/icalendar)[ RSS](/packages/beastbytes-icalendar/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

iCalendar
=========

[](#icalendar)

The iCalendar library provides the ability to create, edit, and import [RFC 5545 - Internet Calendaring and Scheduling (iCalendar)](https://datatracker.ietf.org/doc/html/rfc5545)including properties defined in [RFC 7986 - New Properties for iCalendar](https://datatracker.ietf.org/doc/html/rfc7986).

Creating iCalendars
-------------------

[](#creating-icalendars)

The iCalendar library allows creation of iCalendars in an object-oriented way.

To create an iCalendar, create a new Vcalendar object then add properties and components to it; properties and other components are added to child components in a similar way; multiple components of the same type are supported, as are multiple properties with the same name in a component.

Finally, call the Vcalendar's render() method.

All iCalendar components are immutable.

### UIDs

[](#uids)

VEVENT, VFREEBUSY, VJOURNAL, and VTODO components require the UID property;since RFC 7985 it can also be set in VCALENDAR. RFC 7985 udates the recommendation on how to construct the value; it deprecates the use of IP addresses and host and domain names due particularly due privacy and security concerns, and recommends use of Universally Unique Identifier (UUID) values as defined in Sections [4.4](https://datatracker.ietf.org/doc/html/rfc4122#section-4.4) and [4.5](https://datatracker.ietf.org/doc/html/rfc4122#section-4.5) of [RFC4122](https://datatracker.ietf.org/doc/html/rfc4122).

The library provides a helper method that generates V4 UUIDs.

```
$vCalendar = (new Vcalendar())
    ->addProperty(Vcalendar::PROPERTY_UID, Vcalendar::uuidv4())
    ->addComponent((new Vevent())
        ->addProperty(Vevent::PROPERTY_UID, Vevent::uuidv4())
    )
;
```

### Non-standard Components

[](#non-standard-components)

IANA and X- components can be added to the iCalender object (Vcalendar).

Non-standard components must extend Component and define the NAME constant; they must be registered in Vcalendar before use.

```
use BeastBytes\ICalendar\Component;

class NonStandardComponent extends Component
{
    public const NAME = 'NON-STANDARD-COMPONENT';

    protected const CARDINALITY = [
        // declare cardinality of the component's properties here
    ];
}
---
Vcalendar::registerNonStandardComponent(NonStandardComponent::NAME);

$nonStandardComponent = new NonStandardComponent();

$vCalendar = (new Vcalendar())->addComponent($nonStandardComponent);
// $vCalendar->hasComponent(NonStandardComponent::NAME) === true;
```

### Non-standard Properties

[](#non-standard-properties)

IANA and X- properties can be added to iCalender components.

Non-standard properties must be registered with the component before use; the default cardinality is one or many may be present.

```
public const NON_STANDARD_PROPERTY = 'NON-STANDARD-PROPERTY';

Vevent::registerNonStandardProperty(self::NON_STANDARD_PROPERTY, Vevent::CARDINALITY_ONE_MAY);

$vEvent = (new Vevent())->addProperty(self::NON_STANDARD_PROPERTY, $value);
// $vEvent->hasProperty(self::NON_STANDARD_PROPERTY) === true;
```

### Example

[](#example)

The following example creates a To-Do with an alarm (it is the example on page 146 of RFC5545 modified to use UUID V4 for UID).

```
$iCalendar = (new Vcalendar())
    ->addProperty(Vcalendar::PROPERTY_PRODUCT_IDENTIFIER, '-//ABC Corporation//NONSGML My Product//EN')
    ->addComponent((new Vtodo())
        ->addProperty(Vtodo::PROPERTY_DATETIME_STAMP, '19980130T134500Z')
        ->addProperty(Vtodo::PROPERTY_SEQUENCE, 2)
        ->addProperty(Vtodo::PROPERTY_UID, Vtodo::uuidv4())
        ->addProperty(Vtodo::PROPERTY_ORGANIZER, 'mailto:unclesam@example.com')
        ->addProperty(
            Vtodo::PROPERTY_ATTENDEE,
            'mailto:jqpublic@example.com',
            [
                Vtodo::PARAMETER_PARTICIPATION_STATUS => Vtodo::STATUS_ACCEPTED
            ]
        )
        ->addProperty(Vtodo::PROPERTY_DATETIME_DUE, '19980415T000000')
        ->addProperty(Vtodo::PROPERTY_STATUS, Vtodo::STATUS_NEEDS_ACTION)
        ->addProperty(Vtodo::PROPERTY_SUMMARY, 'Submit Income Taxes')
        ->addComponent((new Valarm())
            ->addProperty(Valarm::PROPERTY_ACTION, Valarm::ACTION_AUDIO)
            ->addProperty(Valarm::PROPERTY_TRIGGER, '19980403T120000Z')
            ->addProperty(
                Valarm::PROPERTY_ATTACH,
                'http://example.com/pub/audio-files/ssbanner.aud',
                [
                    Valarm::PARAMETER_FORMAT_TYPE => 'audio/basic'
                ]
            )
            ->addProperty(Valarm::PROPERTY_REPEAT, 4)
            ->addProperty(Valarm::PROPERTY_DURATION, 'PT1H')
        )
    )
    ->render()
;
```

See tests for more examples.

Edit iCalendar
--------------

[](#edit-icalendar)

iCalendar components can be edited, for example when updating a Vevent.

The library has methods for editing components:

- hasComponent($name) - whether a component has one or more components of type $name
- getComponents() - returns all child components
- getComponent($name) - returns all child components of type $name
- getComponent($name, $n) - returns the $nth occurrence of the child component of type $name
- setComponent($component, $n) - set (overwrite) the $nth occurrence of the type of $component with $component
- removeComponent($name) - remove all child components of type $name
- removeComponent($name, $n) - remove the $nth occurrence of the child component of type $name
- hasProperty($name) - whether a component has one or more properties of type $name
- getProperties() - returns all component properties
- getProperty($name) - returns all component properties of type $name
- getProperty($name, $n) - returns the $nth occurrence of the component property of type $name
- setProperty($name, $n, $value, $parameters) - set (overwrite) the $nth occurrence of the property of type $name with new $value and $parameters
- removeProperty($name) - remove all component properties of type $name
- removeProperty($name, $n) - remove the $nth occurrence of the component property of type $name

Import iCalendar
----------------

[](#import-icalendar)

Import an iCalendar string using Vcalendar::import():

```
$icalendar = Vcalendar::import($string);
```

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

[](#installation)

The preferred way to install the library is with [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist beastbytes/icalendar

```

or add

```
"beastbytes/icalendar": "*"
```

to the 'require' section of your composer.json.

Testing
-------

[](#testing)

### Unit testing

[](#unit-testing)

The package is tested with PHPUnit. To run the tests:

```
./vendor/bin/phpunit

```

### Static analysis

[](#static-analysis)

The code is statically analyzed with Psalm. To run static analysis:

```
./vendor/bin/psalm

```

License
-------

[](#license)

The iCalendar Library is free software. It is released under the terms of the BSD License. For license information see the [LICENSE](LICENSE.md) file.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1104d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0b5133b5137b26eeb25056449c28364ac0af31836eefba78912a9c8f0743aa3?d=identicon)[BeastBytes](/maintainers/BeastBytes)

---

Top Contributors

[![beastbytes](https://avatars.githubusercontent.com/u/1470144?v=4)](https://github.com/beastbytes "beastbytes (20 commits)")

---

Tags

icalendarphprfc5545rfc7986iCalendarRFC 5545RFC 7986

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/beastbytes-icalendar/health.svg)

```
[![Health](https://phpackages.com/badges/beastbytes-icalendar/health.svg)](https://phpackages.com/packages/beastbytes-icalendar)
```

###  Alternatives

[eluceo/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.

1.2k18.7M61](/packages/eluceo-ical)[spatie/icalendar-generator

Build calendars in the iCalendar format

6878.7M19](/packages/spatie-icalendar-generator)[jsvrcek/ics

abstraction layer for creating multi-byte safe RFC 5545 compliant .ics files

2232.0M12](/packages/jsvrcek-ics)[sssurii/laravel-ics

Laravel package to create iCalendar / ICS files. Send new event invitations via Email and can cancel or update already sent invitation.

2162.8k](/packages/sssurii-laravel-ics)[jsvrcek/ics-bundle

This bundle provides a dependency injection wrapper for the JsvrcekICS iCal library

11159.6k](/packages/jsvrcek-ics-bundle)[welp/ical-bundle

Symfony Bundle to manage .ics iCal file (creating and eventually reading)

10116.0k](/packages/welp-ical-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
