PHPackages                             titasgailius/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. titasgailius/calendar

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

titasgailius/calendar
=====================

Calendar is an intuitive abstraction around various calendar providers.

0.1.4(11mo ago)1378↓50%1MITPHPPHP ^8.0CI passing

Since Aug 31Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/TitasGailius/calendar)[ Packagist](https://packagist.org/packages/titasgailius/calendar)[ RSS](/packages/titasgailius-calendar/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (7)Used By (0)

[![](./carbon.png)](./carbon.png)

Calendar
========

[](#calendar)

Easily manage Google &amp; Microsoft calendars.

Setup
=====

[](#setup)

Before managing events, you need to initialise a Google or Microsoft calendar.

### Initializing Google Calendar

[](#initializing-google-calendar)

To initialise a Google calendar, you need to pass client &amp; user credentials and a callback that is run when an expired access token is refreshed.

```
$calendar = Calendar::google(
    client: [
        'client_id' => 'GOOGLE_CLIENT_ID',
        'client_secret' => 'GOOGLE_CLIENT_SECRET',
    ],
    token: [
        'refresh_token' => 'USER_REFRESH_TOKEN',
        'access_token' => 'USER_ACCESS_TOKEN',
        'created' => 1679422799,
        'expires_in' => 1679426399,
    ],
    onTokenRefresh: fn (array $token) => var_dump($token),
);
```

### Initializing Microsoft Calendar

[](#initializing-microsoft-calendar)

To initialise a Microsoft calendar, you may pass user credentials and a callback that is run when an expired access token is refreshed.

```
$calendar = Calendar::microsoft(
    client: [
        'client_id' => 'MICROSOFT_CLIENT_ID',
        'client_secret' => 'MICROSOFT_CLIENT_SECRET',
    ],
    token: [
        'refresh_token' => 'USER_REFRESH_TOKEN',
        'access_token' => 'USER_ACCESS_TOKEN',
        'created' => 1679422799,
        'expires_in' => 1679426399,
    ],
    onTokenRefresh: fn (array $token) => var_dump($token),
);
```

Usage
=====

[](#usage)

Creating Events
---------------

[](#creating-events)

To create a calendar event, simply pass a new `Event` instance to the `createEvent` method.

```
$event = $calendar->createEvent(new Event(
    title: 'My fist event',
    start: Carbon::now()->addMinutes(30),
    end: Carbon::now()->addMinutes(60),
    attendees: ['john.doe@example.com'],
));
```

Retrieving Events
-----------------

[](#retrieving-events)

To retrieve an event, simply pass an `id` of the event to the `getEvent` method.

```
$event = $calendar->getEvent('442d81dvg884c57an0g778e184');
```

Updating Events
---------------

[](#updating-events)

To update an event, simply pass an `Event` instance to the `updateEvent` method.

```
$event->title = 'Updated Event Title';
$calendar->updateEvent($event);
```

Deleting Events
---------------

[](#deleting-events)

To delete an event, simply pass an event id to the `deleteEvent` method.

```
$calendar->deleteEvent('442d81dvg884c57an0g778e184');
```

Listing Events
--------------

[](#listing-events)

To list events, simply call the `getEvents` method. The result of this method is an instance of a `Paginator` object.

```
$paginator = $calendar->getEvents();
```

To loop through all event pages, you may call the `next` method on the `Paginator` instance.

```
while ($events = $paginator->next()) {
    //
}
```

To loop through all events from all pages, you may call the `each` method on the `Paginator` instance and pass a callback that is run with each event instance.

```
$calendar->each(function (Event $event) {
    //
});
```

To collect all events in memory, you may call the `all` method on the `Paginator` instance.

```
$events = $paginator->all();
```

Listing Calendars
-----------------

[](#listing-calendars)

To list calendars, simply call the `getCalendars` method. The result of this method is an instance of a `Paginator` object.

```
$paginator = $calendar->getCalendars();
```

To loop through all calendar pages, you may call the `next` method on the `Paginator` instance.

```
while ($calendars = $paginator->next()) {
    //
}
```

To loop through all calendars from all pages, you may call the `each` method on the `Paginator` instance and pass a callback that is run with each calendar instance.

```
$paginator->each(function (Calendar $calendar) {
    //
});
```

To collect all calendars in memory, you may call the `all` method on the `Paginator` instance.

```
$calendars = $paginator->all();
```

Resources
=========

[](#resources)

Below, you may find FULL definitions of each calendar resource.

```
new Event(
    title: 'My First Calendar Event',
    start: now()->addMinutes(30),
    end: now()->addMinutes(60),
    organiser: new Organiser('john@example.com'),
    attendees: [
        new Attendee(email: 'bob@example.com', rsvp: Rsvp::ACCEPTED),
        new Attendee(email: 'rob@example.com', rsvp: Rsvp::PENDING),
    ],
    calendar: 'primary',
    id: '442d81dvg884c57an0g778e184',
);

new Calendar(
    provider: 'google',
    id: '442d81dvg884c57an0g778e184',
    name: 'Public Holidays Calendar',
);
```

Extending
=========

[](#extending)

To add a new provider, simple implement the `TitasGailius\Calendar\Contracts\Provider` interface for your provider.

```
interface Provider
{
    /**
     * List calendars.
     *
     * @param  mixed[]  $options
     * @return \TitasGailius\Calendar\Contracts\Paginator
     */
    public function getCalendars(array $options = []): Paginator;

    /**
     * List events.
     *
     * @param  mixed[]  $options
     * @return \TitasGailius\Calendar\Contracts\Paginator
     */
    public function getEvents(array $options = []): Paginator;

    /**
     * Create an event.
     *
     * @param  mixed[]  $options
     */
    public function createEvent(Event $event, array $options = []): Event;

    /**
     * Get event.
     *
     * @param  mixed[]  $options
     */
    public function getEvent(string|Event $event, array $options = []): ?Event;

    /**
     * Save a new event.
     *
     * @param  mixed[]  $options
     */
    public function updateEvent(Event $event, array $options = []): Event;

    /**
     * Delete a given event.
     *
     * @param  mixed[]  $options
     */
    public function deleteEvent(string|Event $event, array $options = []): void;
}
```

then, register your custom `Calendar` provider

```
Calendar::extend('calendly', function (array $config = []) {
    return new CalendlyProvider($options);
});
```

Finally, you may retrieve your custom provider by calling the `provider` method

```
$calenar = Calendar::provider('calendly', [
    'token ' => 'CALENDLY_TOKEN',
]);
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance62

Regular maintenance activity

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~67 days

Total

5

Last Release

349d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12625773?v=4)[Titas Gailius](/maintainers/TitasGailius)[@TitasGailius](https://github.com/TitasGailius)

---

Top Contributors

[![TitasGailius](https://avatars.githubusercontent.com/u/12625773?v=4)](https://github.com/TitasGailius "TitasGailius (39 commits)")

---

Tags

symfonylaravelgoogleeventsmicrosoftcalendar

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/titasgailius-calendar/health.svg)

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

###  Alternatives

[spatie/laravel-google-calendar

Manage events on a Google Calendar

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

Office365 Adapter for CalendArt

1213.8k](/packages/calendart-office365-adapter)

PHPackages © 2026

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