itsnubix/nowcal

A modern PHP library for generating iCalendar v2.0 events

1.6.0 2024-10-17 07:59 UTC

This package is auto-updated.

Last update: 2024-11-17 08:13:02 UTC


README

Software License Total Downloads

A modern PHP library for generating iCalendar v2.0 events.

Getting Started

Installation

Install with composer using composer require itsnubix/nowcal

Basic usage

use NowCal\NowCal;

$event = NowCal::create(['start' => 'October 5, 2019 6:03PM']))
  ->summary('Daft Punk is playing')
  ->location('My House');

API

Properties

The following properties can be get/set on the NowCal instance. Users can take advantage of the set property helpers in the class, i.e.: $nowcal->location('Event Location'); as they provide a nice syntax to string multiple calls together and support callbacks if necessary.

Methods

$props = [
  'start' => 'now',
  'end' => 'now + 1 hour',
  // OR
  'duration' => '28d 6h 42m 12s',
  'summary' => 'Daft Punk is playing',
  'location' => 'My House',
];

// Creates a NowCal instance
$nowcal = new NowCal($props); // or NowCal::create($props);

// Exports a raw output array
$nowcal->raw; // or NowCal::raw($props)

// Exports a plain text version
$nowcal->plain; // or NowCal::plain($props)

// Exports a path to a tempfile
$nowcal->file; // or NowCal::file($props)