calendar-links

为 Google、iCal 和其他日历系统生成添加到日历的链接。「Generate add to calendar links for Google, iCal and other calendar systems」

Github星跟蹤圖

Generate add to calendar links for Google, iCal and other calendar systems

Latest Version on Packagist
Total Downloads
Test
Quality Score
Type coverage
Psalm level

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: https://calendar.google.com/calendar/render?action=TEMPLATE&text=Birthday&dates=20180201T090000/20180201T180000&sprop=&sprop=name:

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.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

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.

Installation

You can install the package via composer:

composer require spatie/calendar-links

Usage

<?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();
echo $link->ics(['UID' => 'custom-id']); // Custom UID (to update existing events)
echo $link->ics(['URL' => 'https://my-page.com']); // Custom URL
echo $link->ics(['REMINDER' => []]); // Add the default reminder (for iCal & Outlook)
echo $link->ics(['REMINDER' => ['DESCRIPTION' => 'Remind me', 'TIME' => new \DateTime('tomorrow 12:30 UTC')]]); // Add a custom reminder
echo $link->ics([], ['format' => 'file']); // use file output; e.g. to attach ics as a file to an email.

// Generate a data URI using arbitrary generator:
echo $link->formatWith(new \Your\Generator());

Package principles

  1. it should produce a small output (to keep page-size small)
  2. it should be fast (no any external heavy dependencies)
  3. all Link class features should be supported by at least 2 generators (different services have different features)

Changelog

Please see CHANGELOG for more information.

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security, please mail security@spatie.be instead of using the issue tracker.

Postcardware

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.

Credits

License

The MIT License (MIT). Please see License File for more information.

概覽

名稱與所有者spatie/calendar-links
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證MIT License
發布數36
最新版本名稱2.0-alpha.1 (發布於 )
第一版名稱0.0.1 (發布於 )
創建於2017-09-15 09:14:02
推送於2024-02-19 19:14:23
最后一次提交2024-02-19 20:10:23
星數888
關注者數15
派生數146
提交數396
已啟用問題?
問題數86
打開的問題數3
拉請求數67
打開的拉請求數0
關閉的拉請求數39
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部