pHP 的 iCal 创建器
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.
You can install this package by using Composer, running the following command:
composer require eluceo/ical
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.16 | 8.4 - 8.5 |
| 2.15 | 8.3 - 8.4 |
| \createCalendar($calendar); |
#### 4. a) Save to file
```PHP
file_put_contents('calendar.ics', (string) $iCalendarComponent);
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="cal.ics"');
echo $iCalendarComponent;
The following example will create a single day event with a summary and a description. More examples can be found in the examples/ folder.
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;
This package is released under the MIT license.
暂无开放 Issues,或尚未同步最近议题。