Download the PHP package om/icalparser without Composer
On this page you can find all versions of the php package om/icalparser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download om/icalparser
More information about om/icalparser
Files in om/icalparser
Informations about the package icalparser
PHP iCal Parser
A lightweight and robust iCalendar (RFC 5545) parser for PHP. Documentation: ozzyczech.github.io/icalparser
- reads real-world
.icsfiles from Google Calendar, Apple Calendar, Outlook, Exchange, Nextcloud, Fastmail and others, repairs damaged files and reports every repair - keeps unknown and X- properties, writes calendars back
- creates calendars with named arguments (
Event::new(summary: ..., start: ...)), with VTIMEZONE definitions - keeps the meaning of dates, floating, UTC and zoned times, resolves Windows timezones and custom VTIMEZONE definitions
- expands recurring events lazily: the complete RRULE (including BYSETPOS and BYWEEKNO), RDATE, EXDATE and RECURRENCE-ID overrides (moved, cancelled and THISANDFUTURE)
- safe for untrusted input: strict and permissive mode, resource limits, streaming of large files
Install
Usage
Events, tasks (todos()), journal entries (journals()) and free/busy components (freeBusy()) have typed getters:
uid(), summary(), description(), location(), start(), end(), duration(), status(), categories(),
organizer(), attendees(), alarms(), recurrenceRule(), color(), images() and more, see
reading calendars. Any property, including unknown ones, is available too:
Dates and times
start(), end() and the occurrences return DateTimeValue, which keeps the difference between
20261010 (a date), 20261010T100000 (floating), 20261010T100000Z (UTC) and TZID=Europe/Prague:20261010T100000 (zoned).
Floating times and dates are never converted with the PHP default timezone:
The timezone of dates and floating times is X-WR-TIMEZONE of the calendar or the one configured with
ICal::parser()->floatingTimezone(...). See values and timezones.
Recurring events
Occurrences are generated lazily and only for a window or up to a limit; there is no unlimited expansion. The recurrence engine can be used on its own:
See recurrence.
Strict and permissive parsing
The permissive mode (default) repairs damaged files and reports each repair as a warning. The strict mode throws an exception with an error code, line, property and raw value. Limits of the input and of recurrence expansion protect against pathological files. See validation.
Large files
Creating calendars
Values are formatted and escaped, UID, DTSTAMP and a VTIMEZONE for every timezone used are added, invalid combinations are rejected. Parsed calendars are serialized with all their properties, lines are folded at 75 octets. See creating calendars.
Examples
Recipes show common tasks: reading a feed from a URL, events in the viewer's timezone, JSON for a web calendar, a filtered copy, a subscription feed, e-mail invitations and checking uploads.
The examples directory contains a web page listing upcoming events of a sample calendar
(php -S localhost:8000 -t examples) and command line scripts for streaming, validation and writing.
Upgrading from version 4
The array based IcalParser of version 4 is still available and deprecated (it will be removed in 5.5 at the latest);
it keeps its output and fixes many bugs.
See CHANGELOG.md.
Development
iCal parser uses Nette Tester, PHPStan and PHP CS Fixer.
The differential test needs Python with dateutil and is skipped without it:
python3 -m venv .venv && .venv/bin/pip install python-dateutil, then run it with ICALPARSER_PYTHON=.venv/bin/python.
The documentation at ozzyczech.github.io/icalparser is built by
Starlight from docs/*.md, UPGRADING.md and CHANGELOG.md, and by
ApiGen from the docblocks of src/ (.github/workflows/docs.yml). Preview it with
composer create-project apigen/apigen:dev-master ../apigen --no-dev && php ../apigen/bin/apigen, then
cd website && npm install && npm run dev.
Every calendar in tests/Fixtures has a golden file with the normalized output. After an intended change,
regenerate them with UPDATE_SNAPSHOTS=1 composer test:integration and review the diff. Every bug gets a fixture
in tests/Fixtures/Regression or a test.