spatie / calendar-links
为Google、iCal和其他日历系统生成添加到日历的链接
Requires
- php: ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.49
- phpunit/phpunit: ^10.5
- spatie/phpunit-snapshot-assertions: ^5.1
- vimeo/psalm: ^5.22
This package is auto-updated.
Last update: 2024-09-19 20:28:16 UTC
README
使用此包,您可以生成添加事件到日历系统的链接。以下是一个快速示例
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();
这将输出: https://calendar.google.com/calendar/render?action=TEMPLATE&text=Birthday&dates=20180201T090000/20180201T180000&sprop=&sprop=name:
如果您点击该链接(并且已通过Google认证),您将看到一个可以将事件添加到您的日历的屏幕。
该包还可以生成您可以在Microsoft Outlook、Google Calendar和Apple Calendar等几个电子邮件和日历程序中打开的ics文件。
支持我们
我们投入了大量资源来创建 一流的开放源代码包。您可以通过 购买我们的付费产品之一 来支持我们。
我们非常感谢您从您的家乡寄给我们一张明信片,说明您正在使用我们的哪个包。您可以在 我们的联系页面 上找到我们的地址。我们在 我们的虚拟明信片墙 上发布所有收到的明信片。
安装
您可以通过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(); 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());
包原则
- 它应该产生小的输出(以保持页面大小小)
- 它应该是快速的(没有任何外部重型依赖)
- 所有的
Link
类功能应该由至少2个生成器支持(不同的服务有不同的功能)
变更日志
有关更多信息,请参阅 CHANGELOG。
测试
composer test
贡献
请参阅 CONTRIBUTING 以获取详细信息。
安全
如果您发现有关安全性的错误,请通过 security@spatie.be 邮件联系,而不是使用问题跟踪器。
明信片软件
您可以自由使用此包(它是 MIT许可),但如果它进入了您的生产环境,我们非常感谢您从您的家乡寄给我们一张明信片,说明您正在使用我们的哪个包。
我们的地址是:Spatie,Samberstraat 69D,2060 安特卫普,比利时。
我们将在我们的公司网站上发布所有收到的明信片 这里。
致谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅 许可证文件。