Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Calendar Links

Calendar Links Laravel Package

spatie/calendar-links

Generate "add to calendar" links for Google, iCal/Outlook and other systems from PHP. Create a Link with a title and start/end times (give both an explicit timezone), then call google() or ics() to get a ready-to-use URL.

View on GitHub
Deep Wiki
Context7

Generate add-to-calendar links for Google, iCal, and other calendar systems with a clean PHP API. Create a link from a title, start time, and end time, then call the desired calendar method—for example, ->google()—to get a shareable URL.

Link::create('Birthday party', $start, $end)->google();
  • Multiple calendar targets, including Google and iCal
  • Timezone-aware links using the start date’s IANA timezone
  • UTC fallback for offsets or ambiguous timezone names
  • Simple, fluent API for building event links
  • Framework-agnostic PHP package
Frequently asked questions about Calendar Links
How do I install spatie/calendar-links in a Laravel application?
Run composer require spatie/calendar-links. There is nothing to register: the package ships no service provider, config file or migration, so installation ends at the Composer pull. You then use the Spatie\CalendarLinks\Link class directly in a service, mailable, API resource or Blade component. Check the installed version against your PHP runtime, because 2.x requires PHP 8.3 or newer.
Which Laravel and PHP versions does spatie/calendar-links support?
The package is framework-agnostic and works in Laravel 9 through 12, but the version floor is set by PHP. Release 2.x requires PHP 8.3, which in practice means Laravel 11 or 12, while Laravel 9 and 10 estates on PHP 8.1 or 8.2 must pin to 1.x. The two major lines are not behaviourally identical, so do not treat an upgrade as a drop-in bump.
How do I generate a Google Calendar add-to-calendar link for a Laravel event?
Build a Link with Link::create('Birthday party', $start, $end) and call google() on the result. Pass DateTimeImmutable instances that both carry an explicit named timezone, for example new DateTimeImmutable('2027-03-15 10:00', new DateTimeZone('Europe/Brussels')). The returned string is a plain shareable URL you can render in an anchor tag or expose through an API resource.
Why is the timezone wrong in my generated add-to-calendar link?
Google's ctz parameter is taken from the start date, so a DateTime without an explicit zone falls back to the date.timezone of whichever machine generated the link. Name a place such as Europe/Brussels or US/Pacific rather than an offset or abbreviation: a zone parsed from an ISO 8601 string is named +01:00, and neither that nor CEST gives a calendar service a location to resolve. POSIX rule sets like EST or MST7MDT and the Etc/GMT±N family are also rejected or rewritten to UTC, which drops daylight saving awareness.
How do I create an ICS file or attach a calendar invite to a Laravel email?
Call ics() instead of google() to get an ICS payload exposed as a data URI that works in a download link. For mail, strip the data URI prefix, base64-decode the remainder to get the raw calendar text, and attach it with your mailable's attachData method using a text/calendar MIME type. ICS is the higher-fidelity path, but it is also the one with more correctness risk, so cover all-day events and custom reminders with your own regression tests.
Does spatie/calendar-links support recurring events, attendees or writing to Google Calendar?
No. The package only builds URLs and ICS payloads: it deliberately omits RRULE recurrence, attendee lists, invitations and any server-side calendar writes. There are no credentials and no API calls at runtime, so it cannot create or update an event on someone's calendar. If you need invitations or two-way sync, treat this as a link-building helper and pair it with the Google Calendar API or Microsoft Graph.
Is spatie/calendar-links safe to use with Laravel Octane and queued jobs?
Yes. The Link value object is immutable and every generator is stateless, so nothing is cached between requests or leaked across Octane workers. Using DateTimeImmutable throughout also removes the classic mutate-the-date bugs that bite when the same object is reused. Generating links inside a queued job or an API resource is equally safe.
How do I add a calendar provider that spatie/calendar-links does not ship?
Implement the package's generator contract for your provider and pass an instance to formatWith(new CustomGenerator()) on the Link. This is the sanctioned extension point, because the Link constructor is final and the built-in format constants are private. Keep the custom generator in your own namespace behind an adapter so vendor types stay out of controllers and Blade templates.
How should I test add-to-calendar links in a Laravel test suite?
Assert the exact generated URL or decoded ICS text in feature tests rather than only checking that a link is present, since every generator encodes a third-party URL format with no published stability contract. Add regression tests for your edge cases: all-day inclusivity, custom VALARM reminders, escaping and CRLF handling in ICS output. Wrapping the package in your own AddToCalendarBuilder service keeps those assertions stable if you later swap or upgrade the library.
What are the alternatives to spatie/calendar-links for Laravel?
You can hand-roll the Google and Outlook query strings, use a front-end library such as add-to-calendar-button, or reach for a dedicated ICS writer like eluceo/ical if you only need file generation. The Google Calendar API and Microsoft Graph are the alternatives when you need real invitations, attendees or recurrence. spatie/calendar-links sits in the middle: a small, framework-agnostic helper that covers Google, Yahoo, Outlook web and ICS links without any infrastructure.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
vento/laravel-airbrake
wfeller/laravel-batch
maco-studios/mage-os-installer
busarm/armie
siberfx/laravel-logger
kfteam1991/dcat-admin
dashed/dashed-laposta
dashed/dashed-ecommerce-montaportal
dashed/dashed-ecommerce-etsy
neohq/string-blade-compiler
log1x/acf-composer
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager