PHPackages                             haeliomarcio/laravel-google-calendar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. haeliomarcio/laravel-google-calendar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

haeliomarcio/laravel-google-calendar
====================================

Manage events on a Google Calendar

2.6.3(5y ago)04MITPHPPHP ^7.1

Since May 25Pushed 5y agoCompare

[ Source](https://github.com/haeliomarcio/laravel-google-calendar)[ Packagist](https://packagist.org/packages/haeliomarcio/laravel-google-calendar)[ Docs](https://github.com/spatie/laravel-google-calendar)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/haeliomarcio-laravel-google-calendar/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (6)Versions (27)Used By (0)

Manage events on a Google Calendar
==================================

[](#manage-events-on-a-google-calendar)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a47c398db0c12dac2e6fb2f815f56b171d6ded7dc55942b666424eacd70c7b11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-google-calendar)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![GitHub Workflow Status](https://camo.githubusercontent.com/fa089b6ac31a5f056e45996b6ab6b041557c7181dd278028b600d223e76c84bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722f72756e2d74657374733f6c6162656c3d7465737473)](https://camo.githubusercontent.com/fa089b6ac31a5f056e45996b6ab6b041557c7181dd278028b600d223e76c84bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722f72756e2d74657374733f6c6162656c3d7465737473)[![Quality Score](https://camo.githubusercontent.com/2408e829d44906a6f0ca14264d98ad33e18f81ab611ad652722818d868274f5a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/laravel-google-calendar)[![StyleCI](https://camo.githubusercontent.com/85567fa7e5d71d235604716e48e907fdd4dc4a1ad1bbe0663ca1baa37cbe9aee/68747470733a2f2f7374796c6563692e696f2f7265706f732f35383330353930332f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/58305903)[![Total Downloads](https://camo.githubusercontent.com/1172d5d02f2126c5738a92beeb8d7d5b739ba16a05fcb67924f544742ae38d75/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-google-calendar)

This package makes working with a Google Calendar a breeze. Once it has been set up you can do these things:

```
use Spatie\GoogleCalendar\Event;

//create a new event
$event = new Event;

$event->name = 'A new event';
$event->startDateTime = Carbon\Carbon::now();
$event->endDateTime = Carbon\Carbon::now()->addHour();
$event->addAttendee(['email' => 'youremail@gmail.com']);
$event->addAttendee(['email' => 'anotherEmail@gmail.com']);

$event->save();

// get all future events on a calendar
$events = Event::get();

// update existing event
$firstEvent = $events->first();
$firstEvent->name = 'updated name';
$firstEvent->save();

$firstEvent->update(['name' => 'updated again']);

// create a new event
Event::create([
   'name' => 'A new event',
   'startDateTime' => Carbon\Carbon::now(),
   'endDateTime' => Carbon\Carbon::now()->addHour(),
]);

// delete an event
$event->delete();
```

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

Support us
----------

[](#support-us)

Learn how to create a package like this one, by watching our premium video course:

[![Laravel Package training](https://camo.githubusercontent.com/4c7f3720a29525e627f6004ee367e55def510e45d18e6bc974725812fa5cf257/68747470733a2f2f7370617469652e62652f6769746875622f7061636b6167652d747261696e696e672e6a7067)](https://laravelpackage.training)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-google-calendar
```

You must publish the configuration with this command:

```
php artisan vendor:publish --provider="Spatie\GoogleCalendar\GoogleCalendarServiceProvider"
```

This will publish a file called `google-calendar.php` in your config-directory with these contents:

```
return [
    /*
     * Path to the json file containing the credentials.
     */
    'service_account_credentials_json' => storage_path('app/google-calendar/service-account-credentials.json'),

    /*
     *  The id of the Google Calendar that will be used by default.
     */
    'calendar_id' => env('GOOGLE_CALENDAR_ID'),
];

```

How to obtain the credentials to communicate with Google Calendar
-----------------------------------------------------------------

[](#how-to-obtain-the-credentials-to-communicate-with-google-calendar)

The first thing you’ll need to do is get credentials to use Google's API. I’m assuming that you’ve already created a Google account and are signed in. Head over to [Google API console](https://console.developers.google.com/apis) and click "Select a project" in the header.

[![1](./docs/v2/1.png)](./docs/v2/1.png)

Next up we must specify which APIs the project may consume. From the header, select "Enable APIs and Services".

[![2](./docs/v2/2.png)](./docs/v2/2.png)

On the next page, search for "Calendar" and select "Google Calendar API" from the list.

[![3](./docs/v2/3.png)](./docs/v2/3.png)

From here, press "Enable" to enable the Google Calendar API for this project.

[![4](./docs/v2/4.png)](./docs/v2/4.png)

Now that you've created a project that has access to the Calendar API it's time to download a file with these credentials. Click "Credentials" in the sidebar and then press the "Credentials in APIs &amp; Services" link.

[![5](./docs/v2/5.png)](./docs/v2/5.png)

From this page, open the "Create credentials" drop-down and select "Service account key".

[![6](./docs/v2/6.png)](./docs/v2/6.png)

On the next screen, you can give the service account a name. You can name it anything you’d like. In the service account id you’ll see an email address. We’ll use this email address later on in this guide. Select "JSON" as the key type and click "Create" to download the JSON file. You will get a warning that the service account does not have a role, you can safely ignore this and create the service account without assigning a role.

[![7](./docs/v2/7.png)](./docs/v2/7.png)

Save the json inside your Laravel project at the location specified in the `service_account_credentials_json` key of the config file of this package. Because the json file contains potentially sensitive information, I don't recommend committing it to your git repository.

Now that everything is set up on the API site, we’ll need to configure some things on the Google Calendar site. Head over to Google Calendar and view the settings of the calendar you want to work with via PHP. On the "Share with specific people" tab press the "Add people" button and add the service account id that was displayed when creating credentials on the API site.

[![8](./docs/v2/8.png)](./docs/v2/8.png)

[![9](./docs/v2/9.png)](./docs/v2/9.png)

Scroll down to the "Integrate calendar" section to see the id of the calendar. You need to specify that id in the config file.

[![10](./docs/v2/10.png)](./docs/v2/10.png)

Usage
-----

[](#usage)

### Getting events

[](#getting-events)

You can fetch all events by simply calling `Event::get();` this will return all events of the coming year. An event comes in the form of a `Spatie\GoogleCalendar\Event` object.

The full signature of the function is:

```
public static function get(Carbon $startDateTime = null, Carbon $endDateTime = null, array $queryParameters = [], string $calendarId = null): Collection
```

The parameters you can pass in `$queryParameters` are listed [on the documentation on `list` at the Google Calendar API docs](https://developers.google.com/google-apps/calendar/v3/reference/events/list#request).

### Accessing start and end dates of an event

[](#accessing-start-and-end-dates-of-an-event)

You can use these getters to retrieve start and end date as [Carbon](https://github.com/briannesbitt/Carbon) instances:

```
$events = Event::get();

$events[0]->startDate;
$events[0]->startDateTime;
$events[0]->endDate;
$events[0]->endDateTime;
```

### Creating an event

[](#creating-an-event)

You can just new up a `Spatie\GoogleCalendar\Event`-object

```
$event = new Event;

$event->name = 'A new event';
$event->startDateTime = Carbon\Carbon::now();
$event->endDateTime = Carbon\Carbon::now()->addHour();

$event->save();
```

You can also call `create` statically:

```
Event::create([
   'name' => 'A new event',
   'startDateTime' => Carbon\Carbon::now(),
   'endDateTime' => Carbon\Carbon::now()->addHour(),
]);
```

This will create an event with a specific start and end time. If you want to create a full-day event you must use `startDate` and `endDate` instead of `startDateTime` and `endDateTime`.

```
$event = new Event;

$event->name = 'A new full day event';
$event->startDate = Carbon\Carbon::now();
$event->endDate = Carbon\Carbon::now()->addDay();

$event->save();
```

You can create an event based on a simple text string like this:

```
$event = new Event();

$event->quickSave('Appointment at Somewhere on April 25 10am-10:25am');

// statically
Event::quickCreate('Appointment at Somewhere on April 25 10am-10:25am');
```

### Getting a single event

[](#getting-a-single-event)

Google assigns a unique id to every single event. You can get this id by getting events using the `get` method and getting the `id` property on a `Spatie\GoogleCalendar\Event`-object:

```
// get the id of the first upcoming event in the calendar.
$eventId = Event::get()->first()->id;
```

You can use this id to fetch a single event from Google:

```
Event::find($eventId);
```

### Updating an event

[](#updating-an-event)

Easy, just change some properties and call `save()`:

```
$event = Event::find($eventId);

$event->name = 'My updated title';
$event->save();
```

Alternatively, you can use the update method:

```
$event = Event::find($eventId)

$event->update(['name' => 'My updated title']);
```

### Deleting an event

[](#deleting-an-event)

Nothing to it!

```
$event = Event::find($eventId);

$event->delete();
```

### Limitations

[](#limitations)

The Google Calendar API provides many options. This package doesn't support all of them. For instance, recurring events cannot be managed properly with this package. If you stick to creating events with a name and a date you should be fine.

Upgrading from v1 to v2
-----------------------

[](#upgrading-from-v1-to-v2)

The only major difference between `v1` and `v2` is that under the hood Google API v2 is used instead of v1. Here are the steps required to upgrade:

- rename the config file from `laravel-google-calendar` to `google-calendar`
- in the config file rename the `client_secret_json` key to `service_account_credentials_json`

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

A big thank you to [Sebastiaan Luca](https://github.com/sebastiaanluca) for his big help creating v2 of this package.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 68.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~59 days

Recently: every ~16 days

Total

26

Last Release

2152d ago

Major Versions

1.1.0 → 2.0.02017-07-19

v1.x-dev → 2.2.02018-01-10

2.2.0 → v3.x-dev2018-08-13

PHP version history (3 changes)1.0.0PHP ^7.0

2.3.0PHP ^7.2

2.6.2PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/f69019dede628c08904af31b70e03a11bc83a7fd78daf1bf241c62f7b59ee10b?d=identicon)[haeliomarcio](/maintainers/haeliomarcio)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (84 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (5 commits)")[![mathieutu](https://avatars.githubusercontent.com/u/11351322?v=4)](https://github.com/mathieutu "mathieutu (3 commits)")[![haeliomarcio](https://avatars.githubusercontent.com/u/10519788?v=4)](https://github.com/haeliomarcio "haeliomarcio (2 commits)")[![ttomdewit](https://avatars.githubusercontent.com/u/2845400?v=4)](https://github.com/ttomdewit "ttomdewit (2 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (2 commits)")[![XavRsl](https://avatars.githubusercontent.com/u/1185840?v=4)](https://github.com/XavRsl "XavRsl (2 commits)")[![glendmaatita](https://avatars.githubusercontent.com/u/966956?v=4)](https://github.com/glendmaatita "glendmaatita (1 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (1 commits)")[![hulkur](https://avatars.githubusercontent.com/u/11457732?v=4)](https://github.com/hulkur "hulkur (1 commits)")[![Jeroen-G](https://avatars.githubusercontent.com/u/1116853?v=4)](https://github.com/Jeroen-G "Jeroen-G (1 commits)")[![luqmanrom](https://avatars.githubusercontent.com/u/6434819?v=4)](https://github.com/luqmanrom "luqmanrom (1 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")[![markvaneijk](https://avatars.githubusercontent.com/u/1925388?v=4)](https://github.com/markvaneijk "markvaneijk (1 commits)")[![mohitm15](https://avatars.githubusercontent.com/u/35539313?v=4)](https://github.com/mohitm15 "mohitm15 (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![pkboom](https://avatars.githubusercontent.com/u/13960169?v=4)](https://github.com/pkboom "pkboom (1 commits)")[![radoslav-sulkovsky](https://avatars.githubusercontent.com/u/22241221?v=4)](https://github.com/radoslav-sulkovsky "radoslav-sulkovsky (1 commits)")[![rob1121](https://avatars.githubusercontent.com/u/11769053?v=4)](https://github.com/rob1121 "rob1121 (1 commits)")[![stephensamra](https://avatars.githubusercontent.com/u/8583469?v=4)](https://github.com/stephensamra "stephensamra (1 commits)")

---

Tags

eventgoogleschedulecalendarlaravel-google-calendarHaelioMarcio

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/haeliomarcio-laravel-google-calendar/health.svg)

```
[![Health](https://phpackages.com/badges/haeliomarcio-laravel-google-calendar/health.svg)](https://phpackages.com/packages/haeliomarcio-laravel-google-calendar)
```

###  Alternatives

[spatie/laravel-google-calendar

Manage events on a Google Calendar

1.4k1.5M21](/packages/spatie-laravel-google-calendar)[league/period

Time range API for PHP

7335.4M21](/packages/league-period)[kigkonsult/icalcreator

iCalcreator is the PHP implementation of rfc2445/rfc5545 and rfc updates, management of calendar information

2462.6M16](/packages/kigkonsult-icalcreator)[sebdesign/laravel-state-machine

Winzou State Machine service provider for Laravel

3401.3M1](/packages/sebdesign-laravel-state-machine)[laraveljutsu/zap

A flexible, performant, and developer-friendly schedule management system for Laravel

1.4k69.1k](/packages/laraveljutsu-zap)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
