2018-05-17 15:41:10 +02:00
|
|
|
# PHP iCal Parser
|
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/OzzyCzech/icalparser/PHP%20Tests)](https://github.com/OzzyCzech/icalparser/actions)
|
|
|
|
[![Latest Stable Version](https://poser.pugx.org/om/icalparser/v/stable.png)](https://packagist.org/packages/om/icalparser)
|
|
|
|
[![Total Downloads](https://poser.pugx.org/om/icalparser/downloads.png)](https://packagist.org/packages/om/icalparser)
|
|
|
|
[![Latest Unstable Version](https://poser.pugx.org/om/icalparser/v/unstable.png)](https://packagist.org/packages/om/icalparser)
|
|
|
|
[![License](https://poser.pugx.org/om/icalparser/license.png)](https://packagist.org/packages/om/icalparser)
|
2018-05-17 15:41:10 +02:00
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
Internet Calendaring Parser [rfc2445](https://www.ietf.org/rfc/rfc2445.txt) or iCal parser is simple PHP 7.4+ class for parsing format into array.
|
2018-05-17 15:41:10 +02:00
|
|
|
|
|
|
|
## How to install
|
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
The recommended way to is via Composer:
|
|
|
|
|
|
|
|
```shell script
|
2018-05-17 15:41:10 +02:00
|
|
|
composer require om/icalparser
|
|
|
|
```
|
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
## Usage and example
|
2018-05-17 15:41:10 +02:00
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
2022-04-19 21:15:47 +02:00
|
|
|
use om\IcalParser;
|
2018-05-17 15:41:10 +02:00
|
|
|
require_once '../vendor/autoload.php';
|
2022-04-19 21:15:47 +02:00
|
|
|
|
|
|
|
$cal = new IcalParser();
|
2018-05-17 15:41:10 +02:00
|
|
|
$results = $cal->parseFile(
|
|
|
|
'https://www.google.com/calendar/ical/cs.czech%23holiday%40group.v.calendar.google.com/public/basic.ics'
|
|
|
|
);
|
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
foreach ($cal->getEvents()->sorted() as $event) {
|
|
|
|
printf('%s - %s' . PHP_EOL, $event['DTSTART']->format('j.n.Y'), $event['SUMMARY']);
|
|
|
|
|
2018-05-17 15:41:10 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
You can run example with [PHP Built-in web server](https://www.php.net/manual/en/features.commandline.webserver.php) as follow:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
php -S localhost:8000 -t example
|
|
|
|
```
|
|
|
|
|
2018-05-17 15:41:10 +02:00
|
|
|
## Requirements
|
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
- PHP 7.4+
|
2018-05-17 15:41:10 +02:00
|
|
|
|
|
|
|
## Run tests
|
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
iCal parser using [Nette Tester](https://github.com/nette/tester). The tests can be invoked via [composer](https://getcomposer.org/).
|
2018-05-17 15:41:10 +02:00
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
```shell script
|
2018-05-17 15:41:10 +02:00
|
|
|
composer update
|
2022-04-19 21:15:47 +02:00
|
|
|
composer test
|
2018-05-17 15:41:10 +02:00
|
|
|
```
|
2022-04-19 21:15:47 +02:00
|
|
|
|
2018-05-17 15:41:10 +02:00
|
|
|
## TODO
|
|
|
|
|
2022-04-19 21:15:47 +02:00
|
|
|
- add ATTENDEE support https://www.kanzaki.com/docs/ical/attendee.html
|