ux-calendar-link
Symfony UX CalendarLink: "Add to calendar" links built in PHP and rendered in Twig, for Google, Outlook.com, Office 365 and .ics. Use for CalendarEvent, ux_calendar_link(), ux_calendar_links(), recurrence and reminders.
Install
npx skills add https://github.com/smnandre/symfony-ux-skills/tree/main/skills/ux-calendar-link
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install smnandre-symfony-ux-skills@llmmart
git clone https://github.com/smnandre/symfony-ux-skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole smnandre/symfony-ux-skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
UX CalendarLink
Generate "Add to calendar" links from a PHP event object: Google Calendar, Outlook.com, Office 365, and an iCalendar (.ics) file for Apple Calendar, Outlook desktop, Thunderbird and native clients, as plain links.
Since Symfony UX 3.1+. The package is experimental: its API may still change.
Installation
composer require symfony/ux-calendar-link
Quick Reference
new CalendarEvent(title:, start:, end:, ...) The event
ux_calendar_link(event, 'google') One CalendarLink (provider, label, url)
ux_calendar_links(event) One CalendarLink per registered provider
CalendarRecurrence::weekly(count: 10) RRULE
CalendarReminder::before(minutes: 15) VALARM (.ics only)
Provider names: google, outlook, office365, ics.
Building the Event
use Symfony\UX\CalendarLink\CalendarEvent;
$event = new CalendarEvent(
title: 'Symfony Live Paris',
start: new \DateTimeImmutable('2026-05-14 09:00'),
end: new \DateTimeImmutable('2026-05-15 18:00'),
description: 'Annual Symfony conference in France',
location: 'Cite Universitaire Paris',
url: 'https://live.symfony.com',
);
return $this->render('event/show.html.twig', ['event' => $event]);
| Argument | Type | Notes |
|---|---|---|
title |
string |
Required, must not be blank |
start, end |
\DateTimeInterface |
Required; end must be on or after start |
description, location, url |
?string |
Optional |
allDay |
bool |
Date-only event |
recurrence |
?CalendarRecurrence |
RRULE |
reminders |
list<CalendarReminder> |
VALARM |
uid |
?Uuid |
Since 3.5: stable ICS UID; derived from the event content when omitted |
Invalid input throws Symfony\UX\CalendarLink\Exception\InvalidArgumentException.
Rendering Links
{# One provider #}
<a href="{{ ux_calendar_link(event, 'google').url }}">Add to Google Calendar</a>
{# Every provider #}
<ul class="add-to-calendar">
{% for link in ux_calendar_links(event) %}
<li><a href="{{ link.url }}">{{ link.label }}</a></li>
{% endfor %}
</ul>
A CalendarLink has provider, label and url, and casts to its URL. The ics link is a data:text/calendar URI; add a download attribute so browsers save it as a file:
<a href="{{ ux_calendar_link(event, 'ics') }}" download="event.ics">Download .ics</a>
An unknown provider name throws UnknownProviderException.
Recurrence and Reminders
use Symfony\UX\CalendarLink\CalendarRecurrence;
use Symfony\UX\CalendarLink\CalendarReminder;
$event = new CalendarEvent(
title: 'Weekly sync',
start: new \DateTimeImmutable('2026-05-14 10:00'),
end: new \DateTimeImmutable('2026-05-14 10:30'),
recurrence: CalendarRecurrence::weekly(count: 10),
reminders: [CalendarReminder::before(minutes: 15)],
);
CalendarRecurrence factories: minutely(), daily(), weekly(), monthly(), yearly(), each with interval, count and until named arguments:
CalendarRecurrence::daily(interval: 2);
CalendarRecurrence::monthly(count: 6);
CalendarRecurrence::yearly(until: new \DateTimeImmutable('2030-01-01'));
CalendarReminder::before() sums weeks, days, hours and minutes, with an optional description:
CalendarReminder::before(hours: 1, minutes: 30);
CalendarReminder::before(hours: 2, description: 'Leave early');
Provider Support
| Field | Outlook | Office 365 | ICS | |
|---|---|---|---|---|
| title, start/end, description, location, all-day | yes | yes | yes | yes |
| reminders (VALARM) | ignored | ignored | ignored | yes |
| recurrence (RRULE) | yes | ignored | ignored | yes |
Each link keeps the fields its provider's URL scheme can carry, and silently drops the rest. Google and Outlook ignore minutely() recurrences; use them for ics only.
All-Day Events
$holiday = new CalendarEvent(
title: 'Bastille Day',
start: new \DateTimeImmutable('2026-07-14'),
end: new \DateTimeImmutable('2026-07-14'),
allDay: true,
);
Time Zones
Timed events are written to .ics with their named time zone (TZID plus a matching VTIMEZONE), so recurring events keep their local time across DST changes. Build start and end in the event's real time zone:
new \DateTimeImmutable('2026-05-14 09:00', new \DateTimeZone('Europe/Paris'));
Custom Provider
Implement CalendarLinkProviderInterface and tag the service ux_calendar_link.provider yourself (autoconfiguration skips it):
use Symfony\UX\CalendarLink\CalendarEvent;
use Symfony\UX\CalendarLink\CalendarLink;
use Symfony\UX\CalendarLink\Provider\CalendarLinkProviderInterface;
final class ProtonCalendarLinkProvider implements CalendarLinkProviderInterface
{
public function getName(): string
{
return 'proton';
}
public function getLabel(): string
{
return 'Proton Calendar';
}
public function generate(CalendarEvent $event): CalendarLink
{
return new CalendarLink($this->getName(), $this->getLabel(), $this->buildUrl($event));
}
}
# config/services.yaml
services:
App\Calendar\ProtonCalendarLinkProvider:
tags: ['ux_calendar_link.provider']
Key Principles
Build the event once, render every provider. ux_calendar_links() loops over all registered providers, so the template stays the same when you add one.
Keep the uid stable when it matters. The default UID is derived from the event content, so adding the same event twice keeps a single calendar entry. Pass your own Uuid when the event content can change but must stay the same calendar entry.
References
- Symfony UX package and calendar examples (Markdown summary) ·
symfony/ux-calendar-linkon Packagist. - For providers, reminders, recurrence and all-day events, see the Symfony UX CalendarLink documentation.
See Also
- ux-icons: add a provider icon next to each link with
<twig:ux:icon name="..." /> - twig-component: wrap the link list in an anonymous
<twig:AddToCalendar :event />component
Files (symfony-ux-skills)
-
SKILL.md 6.6 KB
--- name: ux-calendar-link description: 'Symfony UX CalendarLink: "Add to calendar" links built in PHP and rendered in Twig, for Google, Outlook.com, Office 365 and .ics. Use for CalendarEvent, ux_calendar_link(), ux_calendar_links(), recurrence and reminders.' license: MIT metadata: author: Simon André url: https://smnandre.dev --- # UX CalendarLink Generate "Add to calendar" links from a PHP event object: Google Calendar, Outlook.com, Office 365, and an iCalendar (`.ics`) file for Apple Calendar, Outlook desktop, Thunderbird and native clients, as plain links. Since Symfony UX 3.1+. The package is **experimental**: its API may still change. ## Installation ```bash composer require symfony/ux-calendar-link ``` ## Quick Reference ``` new CalendarEvent(title:, start:, end:, ...) The event ux_calendar_link(event, 'google') One CalendarLink (provider, label, url) ux_calendar_links(event) One CalendarLink per registered provider CalendarRecurrence::weekly(count: 10) RRULE CalendarReminder::before(minutes: 15) VALARM (.ics only) ``` Provider names: `google`, `outlook`, `office365`, `ics`. ## Building the Event ```php use Symfony\UX\CalendarLink\CalendarEvent; $event = new CalendarEvent( title: 'Symfony Live Paris', start: new \DateTimeImmutable('2026-05-14 09:00'), end: new \DateTimeImmutable('2026-05-15 18:00'), description: 'Annual Symfony conference in France', location: 'Cite Universitaire Paris', url: 'https://live.symfony.com', ); return $this->render('event/show.html.twig', ['event' => $event]); ``` | Argument | Type | Notes | |----------|------|-------| | `title` | `string` | Required, must not be blank | | `start`, `end` | `\DateTimeInterface` | Required; `end` must be on or after `start` | | `description`, `location`, `url` | `?string` | Optional | | `allDay` | `bool` | Date-only event | | `recurrence` | `?CalendarRecurrence` | RRULE | | `reminders` | `list<CalendarReminder>` | VALARM | | `uid` | `?Uuid` | Since 3.5: stable ICS `UID`; derived from the event content when omitted | Invalid input throws `Symfony\UX\CalendarLink\Exception\InvalidArgumentException`. ## Rendering Links ```twig {# One provider #} <a href="{{ ux_calendar_link(event, 'google').url }}">Add to Google Calendar</a> {# Every provider #} <ul class="add-to-calendar"> {% for link in ux_calendar_links(event) %} <li><a href="{{ link.url }}">{{ link.label }}</a></li> {% endfor %} </ul> ``` A `CalendarLink` has `provider`, `label` and `url`, and casts to its URL. The `ics` link is a `data:text/calendar` URI; add a `download` attribute so browsers save it as a file: ```twig <a href="{{ ux_calendar_link(event, 'ics') }}" download="event.ics">Download .ics</a> ``` An unknown provider name throws `UnknownProviderException`. ## Recurrence and Reminders ```php use Symfony\UX\CalendarLink\CalendarRecurrence; use Symfony\UX\CalendarLink\CalendarReminder; $event = new CalendarEvent( title: 'Weekly sync', start: new \DateTimeImmutable('2026-05-14 10:00'), end: new \DateTimeImmutable('2026-05-14 10:30'), recurrence: CalendarRecurrence::weekly(count: 10), reminders: [CalendarReminder::before(minutes: 15)], ); ``` `CalendarRecurrence` factories: `minutely()`, `daily()`, `weekly()`, `monthly()`, `yearly()`, each with `interval`, `count` and `until` named arguments: ```php CalendarRecurrence::daily(interval: 2); CalendarRecurrence::monthly(count: 6); CalendarRecurrence::yearly(until: new \DateTimeImmutable('2030-01-01')); ``` `CalendarReminder::before()` sums `weeks`, `days`, `hours` and `minutes`, with an optional `description`: ```php CalendarReminder::before(hours: 1, minutes: 30); CalendarReminder::before(hours: 2, description: 'Leave early'); ``` ## Provider Support | Field | Google | Outlook | Office 365 | ICS | |-------|--------|---------|------------|-----| | title, start/end, description, location, all-day | yes | yes | yes | yes | | reminders (VALARM) | ignored | ignored | ignored | yes | | recurrence (RRULE) | yes | ignored | ignored | yes | Each link keeps the fields its provider's URL scheme can carry, and silently drops the rest. Google and Outlook ignore `minutely()` recurrences; use them for `ics` only. ## All-Day Events ```php $holiday = new CalendarEvent( title: 'Bastille Day', start: new \DateTimeImmutable('2026-07-14'), end: new \DateTimeImmutable('2026-07-14'), allDay: true, ); ``` ## Time Zones Timed events are written to `.ics` with their named time zone (`TZID` plus a matching `VTIMEZONE`), so recurring events keep their local time across DST changes. Build `start` and `end` in the event's real time zone: ```php new \DateTimeImmutable('2026-05-14 09:00', new \DateTimeZone('Europe/Paris')); ``` ## Custom Provider Implement `CalendarLinkProviderInterface` and tag the service `ux_calendar_link.provider` yourself (autoconfiguration skips it): ```php use Symfony\UX\CalendarLink\CalendarEvent; use Symfony\UX\CalendarLink\CalendarLink; use Symfony\UX\CalendarLink\Provider\CalendarLinkProviderInterface; final class ProtonCalendarLinkProvider implements CalendarLinkProviderInterface { public function getName(): string { return 'proton'; } public function getLabel(): string { return 'Proton Calendar'; } public function generate(CalendarEvent $event): CalendarLink { return new CalendarLink($this->getName(), $this->getLabel(), $this->buildUrl($event)); } } ``` ```yaml # config/services.yaml services: App\Calendar\ProtonCalendarLinkProvider: tags: ['ux_calendar_link.provider'] ``` ## Key Principles **Build the event once, render every provider.** `ux_calendar_links()` loops over all registered providers, so the template stays the same when you add one. **Keep the `uid` stable when it matters.** The default UID is derived from the event content, so adding the same event twice keeps a single calendar entry. Pass your own `Uuid` when the event content can change but must stay the same calendar entry. ## References - [Symfony UX package and calendar examples](https://ux.symfony.com/calendar-link) ([Markdown summary](https://ux.symfony.com/calendar-link.md)) · [`symfony/ux-calendar-link` on Packagist](https://packagist.org/packages/symfony/ux-calendar-link). - For providers, reminders, recurrence and all-day events, see the [Symfony UX CalendarLink documentation](https://symfony.com/bundles/ux-calendar-link). ## See Also - **ux-icons**: add a provider icon next to each link with `<twig:ux:icon name="..." />` - **twig-component**: wrap the link list in an anonymous `<twig:AddToCalendar :event />` component
Reviews (0)
No reviews yet.
Comments
Sign in to join the conversation.
No comments yet. Start the conversation.