2017 © Pedro Peláez
 

library ical

Provides easy, OO-based iCal generation.

image

tentwofour/ical

Provides easy, OO-based iCal generation.

  • Saturday, July 30, 2016
  • by tentwofour
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Easy iCal Generation

use Doctrine\Common\Collections\ArrayCollection;
use Ten24\Component\Ical\Attendee
use Ten24\Component\Ical\Calendar
use Ten24\Component\Ical\Event

// Rely on date_default_timezone_get()
$c = new Calendar();

// Or pass your own
$c = new Calendar('America/Regina');

// Create a basic event via constructor method
$e1 = new Event(
  'Event Name',
  new \DateTime('2014-01-01 09:00:00'),
  new \DateTime('2014-01-01 10:00:00'),
  new ArrayCollection([
    new Attendee('Ian Bool', 'bool.ian@nowhere.com'),
    new Attendee('Bill Incognito', 'bill.incognito@nowhere.com')
  ]),
  'my-guid');

// Add the event to the calendar
$c->addEvent($e1);

// Or, more complete
$e2 = new Event(
  'Top Secret Event',
  new \DateTime('2014-01-01 09:00:00'),
  new \DateTime('2014-01-01 10:00:00'),
  new ArrayCollection([
    new Attendee('Ian Bool', 'bool.ian@nowhere.com'),
    new Attendee('Bill Incognito', 'bill.incognito@nowhere.com')
  ]),
  'my-guid')
  ->setLocation('Top Secret Location')
  ->setDescription('Trust noone.')
  ->setStatus(Event::STATUS_IN_PROCESS)
  ->setClass(Event::CLASS_PRIVATE)
  //...
  ->setTransparency(Event::TRANSPARENCY_TRANSPARENT);

// Add the event to the calendar
$c->addEvent($e2);

// Or by array, useful when pulling from a db, and hydrating as an array
$events = [[
  'name' => 'Top Secret Event',
  'startDate' => new \DateTime('2014-01-01 09:00:00')
  'endDate' => new \DateTime('2014-01-01 09:00:00'),
  'location' => 'Top Secret Location'
  //...
  ],
  [
  'name' => 'Top Secret Event 2',
  'startDate' => new \DateTime('2014-01-01 09:00:00')
  'endDate' => new \DateTime('2014-01-01 09:00:00'),
  'location' => 'Top Secret Location'
  //...
  ]];

foreach($events as $event)
{
  $e = new Event();
  $c->addEvent($e->fromArray($event));
}

// Get the generated calendar
$icalData = $c->generate();

Running Tests

composer install
phpunit -c phpunit.xml.dist

The Versions

30/07 2016

dev-master

9999999-dev https://github.com/tentwofour/ics

Provides easy, OO-based iCal generation.

  Sources   Download

MIT

The Requires

 

ical ten24 tentwofour