spatie/laravel-google-calendar
Laravel package to manage Google Calendar events with a clean API. Create, update, delete, and fetch events, add attendees and Google Meet links, and work with Carbon date/times. Uses Google service account credentials for authenticated access.
composer require spatie/laravel-google-calendarphp artisan vendor:publish --provider="Spatie\GoogleCalendar\GoogleCalendarServiceProvider"config/google-calendar.php:
service-account-credentials.json (downloaded from Google Cloud Console) in storage/app/google-calendar/ and set default_auth_profile to 'service_account'oauth-credentials.json and oauth-token.json (generated via Google’s PHP quickstart) and set GOOGLE_CALENDAR_AUTH_PROFILE=oauth in .envconfig/google-calendar.php or .env (GOOGLE_CALENDAR_ID)use Spatie\GoogleCalendar\Event;
$event = new Event;
$event->name = 'Team Sync';
$event->startDateTime = now()->addDay();
$event->endDateTime = now()->addDay()->addHour();
$event->save();
Event::create([...]) for simplicity in seeders or batch imports.->id to your database (e.g., google_calendar_id) for later sync/update/delete:
$event = Event::create([...]);
$booking->google_event_id = $event->id;
$booking->save();
$events = Event::get(
startDateTime: now()->startOfWeek(),
endDateTime: now()->endOfWeek(),
queryParameters: ['singleEvents' => true, 'orderBy' => 'startTime']
);
addAttendee() to invite users, and addMeetLink() to auto-generate a Google Meet link for virtual meetings.startDate/endDate (not *DateTime) for multi-day or recurring date boundaries (e.g., conferences, holidays).calendar_id per call: Event::get(calendarId: 'xyz@group.calendar.google.com')Event::find($id) and ignore change attempts to recurring event series—Google’s API treats them differently.startDateTime/endDateTime must be Carbon instances with timezone; set app default via config/app.php#timezone or pass explicit tz: Carbon::now('UTC')->addHour().php artisan google-calendar:refresh-token (if using spatie/laravel-google-calendar v3.6+) or manually refresh. Service accounts skip this step.myapp@project.iam.gserviceaccount.com) as a sharing editor on the target calendar in Google Calendar UI.save()/get() in try/catch and log getErrors() or getMessage().source, colorId, location, and visibility are supported but not obvious—check Event::$availableProperties or source code for full list.How can I help you explore Laravel packages today?