phpfui/icalendar
Composer 安装命令:
composer require phpfui/icalendar
包简介
A modern fork of the icalendar.org PHP implementation of rfc5545, management of iCal formatted files
关键字:
README 文档
README
A modern 7.4 namespaced fork of Zap Calendar iCalendar Library
The Zap Calendar iCalendar Library is a PHP library for supporting the iCalendar (RFC 5545) standard.
This PHP library is for reading and writing iCalendar formatted feeds and files. Features of the library include:
- Read AND write support for iCalendar files
- Object based creation and manipulation of iCalendar files
- Supports expansion of RRULE to a list of repeating dates
- Supports adding timezone info to iCalendar file
All iCalendar data is stored in a PHP object tree. This allows any property to be added to the iCalendar feed without requiring specialized library function calls. With power comes responsibility. Missing or invalid properties can cause the resulting iCalendar file to be invalid. Visit iCalendar.org to view valid properties and test your feed using the site's iCalendar validator tool.
Library API documentation can be found at http://icalendar.org/zapcallibdocs and PHPFUI/ICalendarOrg
See the examples folder for programs that read and write iCalendar files. Best to include the sample files into a file with an active autoloader or include all the classes to run the examples directly.
Create an ical object using the ZCiCal object:
$icalobj = new \ICalendarOrg\ZCiCal();
Add an event object:
$eventobj = new \ICalendarOrg\ZCiCalNode("VEVENT", $icalobj->curnode);
Add a start and end date to the event:
// add start date $eventobj->addNode(new \ICalendarOrg\ZCiCalDataNode("DTSTART:" . \ICalendarOrg\ZDateHelper::fromSqlDateTime("2020-01-01 12:00:00"))); // add end date $eventobj->addNode(new \ICalendarOrg\ZCiCalDataNode("DTEND:" . \ICalendarOrg\ZDateHelper::fromSqlDateTime("2020-01-01 13:00:00")));
Write the object in iCalendar format using the export() function call:
echo $icalobj->export();
This example will not validate since it is missing some required elements. Look at the simpleevent.php example for the minimum # of elements needed for a validated iCalendar file.
To create a multi-event iCalendar file, simply create multiple event objects. For example:
$icalobj = new \ICalendarOrg\ZCiCal(); $eventobj1 = new \ICalendarOrg\ZCiCalNode("VEVENT", $icalobj->curnode); $eventobj1->addNode(new \ICalendarOrg\ZCiCalDataNode("SUMMARY:Event 1")); ... $eventobj2 = new \ICalendarOrg\ZCiCalNode("VEVENT", $icalobj->curnode); $eventobj2->addNode(new \ICalendarOrg\ZCiCalDataNode("SUMMARY:Event 2")); ...
To read an existing iCalendar file/feed, create the ZCiCal object with a string representing the contents of the iCalendar file:
$icalobj = new \ICalendarOrg\ZCiCal($icalstring);
Large iCalendar files can be read in chunks to reduce the amount of memory needed to hold the iCalendar feed in memory. This example reads 500 events at a time:
$icalobj = null; $eventcount = 0; $maxevents = 500; do { $icalobj = new \ICalendarOrg\ZCiCal($icalstring, $maxevents, $eventcount); ... $eventcount += $maxevents; } while($icalobj->countEvents() >= $eventcount);
You can read the events from an imported (or created) iCalendar object in this manner:
foreach($icalobj->tree->child as $node) { if($node->getName() == "VEVENT") { foreach($node->data as $key => $value) { if($key == "SUMMARY") { echo "event title: " . $value->getValues() . "\n"; } } } }
Known Limitations
- Since the library utilizes objects to read and write iCalendar data, the size of the iCalendar data is limited to the amount of available memory on the machine. The ZCiCal() object supports reading a range of events to minimize memory space.
- The library ignores timezone info when importing files, instead utilizing PHP's timezone library for calculations (timezones are supported when exporting files). Imported timezones need to be aliased to a PHP supported timezone.
- At this time, the library does not support the "BYSETPOS" option in RRULE items.
phpfui/icalendar 适用场景与选型建议
phpfui/icalendar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.58k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2019 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「file」 「calendar」 「iCalendar」 「management」 「standard」 「rfc2445」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpfui/icalendar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpfui/icalendar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpfui/icalendar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
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.
Check for holidays - localeaware
Laravel Media Popup to upload/view the files
统计信息
- 总下载量: 15.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2019-11-01