Generate add to calendar links for Google, iCal and other calendar systems
Using this package you can generate links to add events to calendar systems. Here's a quick example:
use Spatie\CalendarLinks\Link; Link::create( 'Birthday', DateTime::createFromFormat('Y-m-d H:i', '2018-02-01 09:00'), DateTime::createFromFormat('Y-m-d H:i', '2018-02-01 18:00') )->google();
This will output:
If you follow that link (and are authenticated with Google) you'll see a screen to add the event to your calendar.
The package can also generate ics files that you can open in several email and calendar programs, including Microsoft Outlook, Google Calendar, and Apple Calendar.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
You can install the package via composer:
composer require spatie/calendar-links
<?php use Spatie\CalendarLinks\Link; $from = DateTime::createFromFormat('Y-m-d H:i', '2018-02-01 09:00'); $to = DateTime::createFromFormat('Y-m-d H:i', '2018-02-01 18:00'); $link = Link::create('Sebastian’s birthday', $from, $to) ->description('Cookies & cocktails!') ->address('Kruikstraat 22, 2018 Antwerpen'); // Generate a link to create an event on Google calendar echo $link->google(); // Generate a link to create an event on Yahoo calendar echo $link->yahoo(); // Generate a link to create an event on outlook.live.com calendar echo $link->webOutlook(); // Generate a link to create an event on outlook.office.com calendar echo $link->webOffice(); // Generate a data uri for an ics file (for iCal & Outlook) echo $link->ics(); // Generate a data URI using arbitrary generator: echo $link->formatWith(new \Your\Generator());
⚠️ ICS download links don't work in IE and EdgeHTML-based Edge browsers, see details.
- it should produce a small output (to keep pagesize small)
- it should be fast (no any external heavy dependencies)
- all features should be supported by at least 2 generators (different services have different features)
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you've found a bug regarding security please mail email@example.com instead of using the issue tracker.
You're free to use this package (it's MIT-licensed), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.
We publish all received postcards on our company website.
The MIT License (MIT). Please see License File for more information.