OzzyCzech / icalparser

Simple ical parser for PHP
https://ozana.cz
BSD 3-Clause "New" or "Revised" License
59 stars 22 forks source link
calendar ical icalendar parser php

Packagist Version Packagist Downloads Packagist License Packagist PHP Version PHP Tests

PHP iCal Parser

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:

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

php -S localhost:8000 -t example

Requirements

Run tests

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

composer update
composer test