PHPackages                             hamedmax73/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. hamedmax73/laravel-google-calendar

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

hamedmax73/laravel-google-calendar
==================================

Manage events on a Google Calendar with google meet

3.6.0(4y ago)021MITPHPPHP ^7.2|^8.0

Since May 25Pushed 4y agoCompare

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

READMEChangelog (1)Dependencies (6)Versions (36)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)[![Test Status](https://camo.githubusercontent.com/fa089b6ac31a5f056e45996b6ab6b041557c7181dd278028b600d223e76c84bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722f72756e2d74657374733f6c6162656c3d7465737473)](https://camo.githubusercontent.com/fa089b6ac31a5f056e45996b6ab6b041557c7181dd278028b600d223e76c84bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722f72756e2d74657374733f6c6162656c3d7465737473)[![Code Style Status](https://camo.githubusercontent.com/d0bce7aff43d3fbd78e3c9d6b1d28650cde670d13dfb25d69ec1a6b868cf2225/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://camo.githubusercontent.com/d0bce7aff43d3fbd78e3c9d6b1d28650cde670d13dfb25d69ec1a6b868cf2225/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d676f6f676c652d63616c656e6461722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)[![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->description = 'Event description';
$event->startDateTime = Carbon\Carbon::now();
$event->endDateTime = Carbon\Carbon::now()->addHour();
$event->addAttendee([
    'email' => 'john@example.com',
    'name' => 'John Doe',
    'comment' => 'Lorum ipsum',
]);
$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)

[![](https://camo.githubusercontent.com/e41d68b26039ae845001042d4e56b3bded0269cff965baa7a4ddc8e948cf45b8/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d676f6f676c652d63616c656e6461722e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-google-calendar)

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 hamedmax73/laravel-google-calendar
```

You must publish the configuration with this command:

```
php artisan vendor:publish --provider="hamedmax73\laravel-google-calender\GoogleCalendarServiceProvider"
```

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

```
return [

    'default_auth_profile' => env('GOOGLE_CALENDAR_AUTH_PROFILE', 'service_account'),

    'auth_profiles' => [

        /*
         * Authenticate using a service account.
         */
        'service_account' => [
            /*
             * Path to the json file containing the credentials.
             */
            'credentials_json' => storage_path('app/google-calendar/service-account-credentials.json'),
        ],

        /*
         * Authenticate with actual google user account.
         */
        'oauth' => [
            /*
             * Path to the json file containing the oauth2 credentials.
             */
            'credentials_json' => storage_path('app/google-calendar/oauth-credentials.json'),

            /*
             * Path to the json file containing the oauth2 token.
             */
            'token_json' => storage_path('app/google-calendar/oauth-token.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.

If you have delegated domain-wide access to the service account and you want to impersonate a user account, specify the email address of the user account in the config file.

[![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)

### Authentication with OAuth2

[](#authentication-with-oauth2)

This package supports OAuth2 authentication. This allows you to authenticate with an actual Google account, and to create and manage events with your own Google account.

OAuth2 authentication requires a token file, in addition to the credentials file. The easiest way to generate both of these files is by using the [php quickstart tool](https://developers.google.com/calendar/quickstart/php). Following this guide will generate two files, `credentials.json` and `token.json`. They must be saved to your project as `oauth-credentials.json` and `oauth-token.json`, respectively. Check the config file in this package for exact details on where to save these files.

To use OAuth2, you must also set a new environment variable in your .env file:

```
GOOGLE_CALENDAR_AUTH_PROFILE=oauth
```

If you are upgrading from an older version of this package, you will need to force a publish of the configuration:

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

Finally, for a more seamless experience in your application, instead of using the quickstart tool you can set up a consent screen in the [Google API console](https://console.developers.google.com/apis). This would allow non-technical users of your application to easily generate their own tokens. This is completely optional.

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 also get the id after creating the event, then you can save it to database.
$event = new Event;
$newEvent = $event->save();
echo $newEvent->id; // displey the event 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();
```

Setting a source
----------------

[](#setting-a-source)

You can set source urls in your events, which are only visible to the creator of the event (see [docs](https://developers.google.com/calendar/v3/reference/events) for more on the source property). This function only works when authenticated via OAuth.

```
$yourEvent->source = [
   'title' => 'Test Source Title',
   'url' => 'http://testsource.url',
 ];
```

### 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](.github/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

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 64.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 ~63 days

Recently: every ~78 days

Total

34

Last Release

1541d 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

2.6.2 → 3.0.02020-08-22

PHP version history (3 changes)1.0.0PHP ^7.0

2.3.0PHP ^7.2

3.2.1PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4779c55d7a3df052c53b72607ddc61b0e90167bbb7abc6d4a0ca616d1d424d21?d=identicon)[hamedmax73](/maintainers/hamedmax73)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (92 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (5 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (5 commits)")[![hamedmax73](https://avatars.githubusercontent.com/u/15096080?v=4)](https://github.com/hamedmax73 "hamedmax73 (3 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (3 commits)")[![iAmKevinMcKee](https://avatars.githubusercontent.com/u/4503765?v=4)](https://github.com/iAmKevinMcKee "iAmKevinMcKee (3 commits)")[![mathieutu](https://avatars.githubusercontent.com/u/11351322?v=4)](https://github.com/mathieutu "mathieutu (3 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)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (2 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (2 commits)")[![ttomdewit](https://avatars.githubusercontent.com/u/2845400?v=4)](https://github.com/ttomdewit "ttomdewit (2 commits)")[![markvaneijk](https://avatars.githubusercontent.com/u/1925388?v=4)](https://github.com/markvaneijk "markvaneijk (1 commits)")[![hulkur](https://avatars.githubusercontent.com/u/11457732?v=4)](https://github.com/hulkur "hulkur (1 commits)")[![mohitm15](https://avatars.githubusercontent.com/u/35539313?v=4)](https://github.com/mohitm15 "mohitm15 (1 commits)")[![mul14](https://avatars.githubusercontent.com/u/113989?v=4)](https://github.com/mul14 "mul14 (1 commits)")[![devsrv](https://avatars.githubusercontent.com/u/26733312?v=4)](https://github.com/devsrv "devsrv (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)")

---

Tags

eventspatiegoogleschedulecalendarlaravel-google-calendar

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/hamedmax73-laravel-google-calendar/health.svg)](https://phpackages.com/packages/hamedmax73-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)
