PHPackages                             elchristo/calendar - 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. elchristo/calendar

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

elchristo/calendar
==================

PHP component to build and convert source based calendars

2.1(7y ago)3171[1 issues](https://github.com/elchristo/calendar/issues)MITPHPPHP ^7.0

Since Feb 21Pushed 7y ago2 watchersCompare

[ Source](https://github.com/elchristo/calendar)[ Packagist](https://packagist.org/packages/elchristo/calendar)[ RSS](/packages/elchristo-calendar/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (8)Versions (13)Used By (0)

Calendar builder and converter
==============================

[](#calendar-builder-and-converter)

Master : [![Build Status](https://camo.githubusercontent.com/21db3bba4bd51c1a0dc2a6733c975a90ca4103f9e90016a8591ed606121b76a9/68747470733a2f2f7472617669732d63692e6f72672f656c6368726973746f2f63616c656e6461722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/elchristo/calendar)

`Calendar` is a PHP library to create custom calendars composed of self defined event sources. Created calendars can be easily converted into various output formats (eg. Json, iCalendar (ics), FullCalendar, ...).

Table of Contents
=================

[](#table-of-contents)

- Installation
- Basic usage
- Full example
- Options
- Converters
- Tests

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

[](#installation)

```
composer require elchristo/calendar

```

Basic usage
-----------

[](#basic-usage)

```
// (1) service container (used to retrieve calendars, sources, events etc.)
// see full example below for use of own service container
$services = include 'config/services.config.php';
$serviceContainer = new Zend\ServiceManager\ServiceManager($services);

// (2) calendar builder
$config = include 'config/config.php'; // optional config array (see configuration section below)
$calendarBuilder = $serviceContainer->build(CalendarBuilder::class, $config);
$calendar = $calendarBuilder->build('SomeCalendarName');
$calendar->addSource(SomeCalendarSource::class);
$events = $calendar->getEvents(); // retrieve traversable collection of calendar events

// convert calendar into json
$json = Converter::convert($calendar, 'json'); // second parameter can as well be a converter classname

// convert calendar into "iCalendar" format (RFC 2445, VCALENDAR)
$ics = Converter::convert($calendar, 'ical'); // second parameter can as well be a converter classname

// convert calendar into "FullCalendar" JSON format (see https://github.com/fullcalendar/fullcalendar)
$fcJson = Converter::convert($calendar, 'FullCalendar');

```

Full example
------------

[](#full-example)

### Configuration

[](#configuration)

The optional configuration gives you the possibility to declare your own converters as well as event colors and color strategies. If no configuration is passed to the `CalendarBuilderFactory` an empty configuration is created internally.

Below you can see a basic example configuration file :

```
