1
0
Fork 0
forked from ChCh/chch_api
chch_api/include/icalparser
2023-07-16 02:51:26 +02:00
..
bin update icalparser to 1e68aae75dbac8f7c27df7b047c0404154d436c4 (supports php 8.2) 2023-07-16 02:51:26 +02:00
example update icalparser to 1e68aae75dbac8f7c27df7b047c0404154d436c4 (supports php 8.2) 2023-07-16 02:51:26 +02:00
src update icalparser to 1e68aae75dbac8f7c27df7b047c0404154d436c4 (supports php 8.2) 2023-07-16 02:51:26 +02:00
tests update icalparser to 1e68aae75dbac8f7c27df7b047c0404154d436c4 (supports php 8.2) 2023-07-16 02:51:26 +02:00
tools Revert "upgrade icalparser from e6a3a285cf6e239236a40153a66b67b940220b43 to cae1631b9496a7415ef960b0dff1cd0f39fe3135" 2023-04-23 13:28:43 +02:00
.travis.yml Revert "upgrade icalparser from e6a3a285cf6e239236a40153a66b67b940220b43 to cae1631b9496a7415ef960b0dff1cd0f39fe3135" 2023-04-23 13:28:43 +02:00
composer.json update icalparser to 1e68aae75dbac8f7c27df7b047c0404154d436c4 (supports php 8.2) 2023-07-16 02:51:26 +02:00
LICENSE update icalparser to 1e68aae75dbac8f7c27df7b047c0404154d436c4 (supports php 8.2) 2023-07-16 02:51:26 +02:00
readme.md update icalparser to 1e68aae75dbac8f7c27df7b047c0404154d436c4 (supports php 8.2) 2023-07-16 02:51:26 +02:00

PHP iCal Parser

PHP Tests Latest Stable Version Total Downloads License PHP Version Require

Internet Calendaring Parser rfc2445 or iCal parser is simple PHP class for parsing format into array.

"Buy Me A Coffee"

How to install

The recommended way to is via Composer:

composer require om/icalparser

Usage and example

<?php
use om\IcalParser;
require_once '../vendor/autoload.php';

$cal = new IcalParser();
$results = $cal->parseFile(
	'https://www.google.com/calendar/ical/cs.czech%23holiday%40group.v.calendar.google.com/public/basic.ics'
);

foreach ($cal->getEvents()->sorted() as $event) {
	printf('%s - %s' . PHP_EOL, $event['DTSTART']->format('j.n.Y'), $event['SUMMARY']);
	
}

Each property of each event is available using the property name (in capital letters) as a key. There are some special cases:

  • multiple attendees with individual parameters: use ATTENDEES as key to get all attendees in the following scheme:
[
	[
		'ROLE' => 'REQ-PARTICIPANT',
		'PARTSTAT' => 'NEEDS-ACTION',
		'CN' => 'John Doe',
		'VALUE' => 'mailto:john.doe@example.org'
	],
	[
		'ROLE' => 'REQ-PARTICIPANT',
		'PARTSTAT' => 'NEEDS-ACTION',
		'CN' => 'Test Example',
		'VALUE' => 'mailto:test@example.org'
	]
]
  • organizer's name: the CN parameter of the organizer property can be retrieved using the key ORGANIZER-CN

You can run example with PHP Built-in web server as follow:

php -S localhost:8000 -t example

Requirements

  • PHP 8.0+

Run tests

iCal parser using Nette Tester. The tests can be invoked via composer.

composer update
composer test