PHPackages                             rob-lester-jr04/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. rob-lester-jr04/laravel-google-calendar

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

rob-lester-jr04/laravel-google-calendar
=======================================

Manage events on a Google Calendar

2.2.2(7y ago)072MITPHPPHP ^7.0

Since May 25Pushed 5y agoCompare

[ Source](https://github.com/roblesterjr04/laravel-google-calendar)[ Packagist](https://packagist.org/packages/rob-lester-jr04/laravel-google-calendar)[ Docs](https://github.com/spatie/laravel-google-calendar)[ RSS](/packages/rob-lester-jr04-laravel-google-calendar/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (6)Versions (15)Used By (0)

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/1dfc6b0ef539cd3919ca7d773ce28ce397485edf1fe61b46640a01bbaa3f4d87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f622d6c65737465722d6a7230342f6c61726176656c2d676f6f676c652d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rob-lester-jr04/laravel-google-calendar)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/dec95b2b5054f69834b9d065ef90ad386541d988d1fd0cb3ce4d455303c3a2cb/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f726f622d6c65737465722d6a7230342f6c61726176656c2d676f6f676c652d63616c656e6461722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/rob-lester-jr04/laravel-google-calendar)[![Quality Score](https://camo.githubusercontent.com/5140fcc1407010a2b648899881ba89bfaf290ad99ab603139dd9b036ea01437d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f726f622d6c65737465722d6a7230342f6c61726176656c2d676f6f676c652d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/rob-lester-jr04/laravel-google-calendar)[![StyleCI](https://camo.githubusercontent.com/85567fa7e5d71d235604716e48e907fdd4dc4a1ad1bbe0663ca1baa37cbe9aee/68747470733a2f2f7374796c6563692e696f2f7265706f732f35383330353930332f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/58305903)[![Total Downloads](https://camo.githubusercontent.com/6965da4ad2c67ad92e0ab8c4c13b3e340988f2f55653ef4dc1e9084ac63b074a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f622d6c65737465722d6a7230342f6c61726176656c2d676f6f676c652d63616c656e6461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rob-lester-jr04/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 Lester\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();
```

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

[](#installation)

You can install the package via composer:

```
composer require rob-lester-jr04/laravel-google-calendar
```

Next up the service provider must be registered:

```
'providers' => [
    ...
    Lester\GoogleCalendar\GoogleCalendarServiceProvider::class,
];
```

Optionally the `Lester\GoogleCalendar\GoogleCalendarFacade` must be registered:

```
'aliases' => [
	...
    'GoogleCalendar' => Lester\GoogleCalendar\GoogleCalendarFacade::class,
    ...
]
```

You must publish the configuration with this command:

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

This will publish file called `google-calendar.php` in your config-directory with this 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 to get some credentials to use Google API’s. 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](https://camo.githubusercontent.com/422358a32a9bf94363370ef0947ad9c10667e6d6e3b5ea79bd04e4d4001a5d02/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f312e6a7067)](https://camo.githubusercontent.com/422358a32a9bf94363370ef0947ad9c10667e6d6e3b5ea79bd04e4d4001a5d02/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f312e6a7067)

Next up we must specify which API's the project may consume. In the list of available API's click "Google Calendar API". On the next screen click "Enable".

[![2](https://camo.githubusercontent.com/5b3233feca97510b795d2d94f3a220c2737fdbd3410da410975cb554afe4e52b/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f322e6a7067)](https://camo.githubusercontent.com/5b3233feca97510b795d2d94f3a220c2737fdbd3410da410975cb554afe4e52b/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f322e6a7067)

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. You'll want to create a "Service account key".

[![3](https://camo.githubusercontent.com/244710e0a7b6b5801dcdde3db415eac96e537721a11add4733e3de234fb84b8d/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f332e6a7067)](https://camo.githubusercontent.com/244710e0a7b6b5801dcdde3db415eac96e537721a11add4733e3de234fb84b8d/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f332e6a7067)

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.

[![4](https://camo.githubusercontent.com/ba1b33e90126408ed0fd4e38b71e3133c7ded9300fcba3597f481c7eae9fc741/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f342e6a7067)](https://camo.githubusercontent.com/ba1b33e90126408ed0fd4e38b71e3133c7ded9300fcba3597f481c7eae9fc741/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f342e6a7067)

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 Google Calendar and view the settings of the calendar you want to work with via PHP. On the “Share this Calendar” tab add the service account id that was displayed when creating credentials on the API site.

[![5](https://camo.githubusercontent.com/a6d26e37a3513f0b8c33f40d24dbaf4a50706301c6cd02ca3b49d7bad8af0110/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f352e6a7067)](https://camo.githubusercontent.com/a6d26e37a3513f0b8c33f40d24dbaf4a50706301c6cd02ca3b49d7bad8af0110/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f352e6a7067)

Open up the “Calendar Details” tab to see the id of the calendar. You need to specify that id in the config file.

[![6](https://camo.githubusercontent.com/91e3b872e3d701b52b92a87ac71c3ab5cdc73d69b9dd4e4f624b6ce198428b4c/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f362e6a7067)](https://camo.githubusercontent.com/91e3b872e3d701b52b92a87ac71c3ab5cdc73d69b9dd4e4f624b6ce198428b4c/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d676f6f676c652d63616c656e6461722f76322f362e6a7067)

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 `Lester\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 `Lester\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();
```

### 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 `Lester\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 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)

This is a Fork of [Spatie's google calendar package](https://github.com/spatie/laravel-google-calendar)

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 70.7% 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 ~77 days

Recently: every ~124 days

Total

14

Last Release

2631d ago

Major Versions

1.1.0 → 2.0.02017-07-19

1.2.0 → 2.2.02018-01-10

2.2.0 → v3.x-dev2018-08-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/37a376a6bb4b688512897fd2afdef71c99a37529f1b3002d43d699843eb9cbc7?d=identicon)[roblesterjr04](/maintainers/roblesterjr04)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (65 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (4 commits)")[![ttomdewit](https://avatars.githubusercontent.com/u/2845400?v=4)](https://github.com/ttomdewit "ttomdewit (2 commits)")[![XavRsl](https://avatars.githubusercontent.com/u/1185840?v=4)](https://github.com/XavRsl "XavRsl (2 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (2 commits)")[![Darival](https://avatars.githubusercontent.com/u/10416020?v=4)](https://github.com/Darival "Darival (1 commits)")[![FabianHippmann](https://avatars.githubusercontent.com/u/13038922?v=4)](https://github.com/FabianHippmann "FabianHippmann (1 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)")[![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)")[![mathieutu](https://avatars.githubusercontent.com/u/11351322?v=4)](https://github.com/mathieutu "mathieutu (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![rob1121](https://avatars.githubusercontent.com/u/11769053?v=4)](https://github.com/rob1121 "rob1121 (1 commits)")[![roblesterjr04](https://avatars.githubusercontent.com/u/6423115?v=4)](https://github.com/roblesterjr04 "roblesterjr04 (1 commits)")[![Zn4rK](https://avatars.githubusercontent.com/u/873043?v=4)](https://github.com/Zn4rK "Zn4rK (1 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (1 commits)")[![awgv](https://avatars.githubusercontent.com/u/6409354?v=4)](https://github.com/awgv "awgv (1 commits)")

---

Tags

eventspatiegoogleschedulecalendarlaravel-google-calendar

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-google-calendar

Manage events on a Google Calendar

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

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[spatie/laravel-event-sourcing

The easiest way to get started with event sourcing in Laravel

9003.7M26](/packages/spatie-laravel-event-sourcing)

PHPackages © 2026

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