codephix/ical
Composer 安装命令:
composer require codephix/ical
包简介
The eluceo/iCal package offers an abstraction layer for creating iCalendars. You can easily create iCal files by using PHP objects instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.
README 文档
README
This package offers an abstraction layer for creating iCalendars files.
By using this PHP package, you can create *.ics files without the knowledge of the underling format.
The output itself will follow RFC 5545 as good as possible.
Navigate through the project
- 📖 read the documentation
- 🐛 report a bug or suggest a feature
- 🙋 raise a question
- 💬 start a discussion
Installation
You can install this package by using Composer, running the following command:
composer require eluceo/ical
Version / Upgrade
The initial version was released back in 2012.
The version 2 of this package is a complete rewrite of the package and is not compatible to older version.
Please see the upgrade guide if you want to migrate from version 0.* to 2.*.
If you just start using this package, you should install version 2.
| Version | PHP Version |
|---|---|
| 2.* | 7.4 - 8.2 |
| 0.16.* | 7.0 - 8.2 |
| 0.11.* | 5.3.0 - 7.4 |
Documentation
Visit ical.poerschke.nrw for complete documentation.
Usage
The classes within this package are grouped into two namespaces:
- The
Domaincontains the information about the events. - The
Presentationcontains the transformation fromDomaininto a*.icsfile.
To create a calendar, the first step will be to create the corresponding domain objects. Then these objects can be transformed into a iCalendar PHP representation, which can be cast to string.
Empty event
In this very basic example, that renders an empty event. You will learn how to create an event domain object, how to add it to a calendar and how to transform it to a iCalendar component.
1. Create an event domain entity
$event = new \Eluceo\iCal\Domain\Entity\Event();
2. Create a calendar domain entity
$calendar = new \Eluceo\iCal\Domain\Entity\Calendar([$event]);
3. Transform calendar domain object into a presentation object
$iCalendarComponent = (new \Eluceo\iCal\Presentation\Factory\CalendarFactory())->createCalendar($calendar);
4. a) Save to file
file_put_contents('calendar.ics', (string) $iCalendarComponent);
4. b) Send via HTTP
header('Content-Type: text/calendar; charset=utf-8'); header('Content-Disposition: attachment; filename="cal.ics"'); echo $iCalendarComponent;
Full example
The following example will create a single day event with a summary and a description. More examples can be found in the examples/ folder.
<?php require_once __DIR__ . '/../vendor/autoload.php'; // 1. Create Event domain entity $event = (new Eluceo\iCal\Domain\Entity\Event()) ->setSummary('Christmas Eve') ->setDescription('Lorem Ipsum Dolor...') ->setOccurrence( new Eluceo\iCal\Domain\ValueObject\SingleDay( new Eluceo\iCal\Domain\ValueObject\Date( \DateTimeImmutable::createFromFormat('Y-m-d', '2030-12-24') ) ) ); // 2. Create Calendar domain entity $calendar = new Eluceo\iCal\Domain\Entity\Calendar([$event]); // 3. Transform domain entity into an iCalendar component $componentFactory = new Eluceo\iCal\Presentation\Factory\CalendarFactory(); $calendarComponent = $componentFactory->createCalendar($calendar); // 4. Set headers header('Content-Type: text/calendar; charset=utf-8'); header('Content-Disposition: attachment; filename="cal.ics"'); // 5. Output echo $calendarComponent;
License
This package is released under the MIT license.
codephix/ical 适用场景与选型建议
codephix/ical 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「calendar」 「iCalendar」 「ics」 「ical」 「php calendar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codephix/ical 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codephix/ical 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codephix/ical 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package developed for easy integration of ics-file generating.
Endroid Calendar
A modern PHP library for generating iCalendar v2.0 events
Tools for parsing & formatting the RFC 2445 iCalendar (.ics) specification
A powerful event calendar Tool for Laravel's Nova 5.
Symfony Bundle to manage .ics iCal file (creating and eventually reading), forked for synfony 6
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-10