定制 chetansingh/calendar-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chetansingh/calendar-manager

Composer 安装命令:

composer require chetansingh/calendar-manager

包简介

Calendar management package for Google Calendar and Microsoft Outlook calendars.

README 文档

README

Calendar Manager is a Composer package for working with Google Calendar and Microsoft Outlook calendars through one small PHP API.

Features

  • Google Calendar OAuth URL and callback token exchange
  • Google access token refresh helper
  • Google Calendar event create, update, delete, get, list, reschedule, cancel
  • Microsoft Graph Outlook event create, update, delete, get, list, reschedule, cancel
  • Simple quickCreate event helper for Google and Outlook
  • Google Meet and Microsoft Teams online meeting helpers
  • Search, date-range listing, and normalized event arrays
  • Availability checks for Google free/busy and Microsoft Graph getSchedule
  • Per-driver configuration with sensible defaults

Installation

composer require chetansingh/calendar-manager

Usage

<?php

require __DIR__ . '/vendor/autoload.php';

use Chetansingh\CalendarManager\Services\CalendarManager;

$calendar = new CalendarManager([
    'drivers' => [
        'google' => [
            'client_id' => 'google-client-id',
            'client_secret' => 'google-client-secret',
            'redirect_uri' => 'https://your-app.test/google/callback',
            'access_token' => $googleAccessToken,
            'calendar_id' => 'primary',
        ],
        'outlook' => [
            'access_token' => $microsoftGraphAccessToken,
            'user_email' => 'person@example.com',
        ],
    ],
]);

echo $calendar->driver('google')->getAuthUrl();

The manager also accepts flat Google configuration for simple apps:

$calendar = new CalendarManager([
    'client_id' => 'google-client-id',
    'client_secret' => 'google-client-secret',
    'redirect_uri' => 'https://your-app.test/google/callback',
]);

Google OAuth Flow

First send the user to Google's consent screen:

<?php

require __DIR__ . '/vendor/autoload.php';

use Chetansingh\CalendarManager\Services\CalendarManager;

$calendar = new CalendarManager([
    'client_id' => 'google-client-id',
    'client_secret' => 'google-client-secret',
    'redirect_uri' => 'https://your-app.test/google-callback.php',
]);

header('Location: ' . $calendar->driver('google')->getAuthUrl());
exit;

Then handle the callback URL configured in Google Cloud:

<?php

session_start();

require __DIR__ . '/vendor/autoload.php';

use Chetansingh\CalendarManager\Services\CalendarManager;

$calendar = new CalendarManager([
    'client_id' => 'google-client-id',
    'client_secret' => 'google-client-secret',
    'redirect_uri' => 'https://your-app.test/google-callback.php',
]);

if (empty($_GET['code'])) {
    exit('Google authorization code missing.');
}

$token = $calendar->driver('google')->handleCallback($_GET['code']);

if (!empty($token['error'])) {
    exit('Google auth failed: ' . ($token['error_description'] ?? $token['error']));
}

// Store this token for the logged-in user.
// In production, save it in your database, encrypted if possible.
$_SESSION['google_access_token'] = $token;

header('Location: /calendar.php');
exit;

For real applications, store the token against your user record. You will need the access_token for API calls and the refresh_token to get a new access token when the old one expires. Google usually returns a refresh token only on the first consent, so do not overwrite an existing stored refresh token with an empty value.

Use the stored token when calling calendar APIs:

session_start();

$calendar = new CalendarManager([
    'client_id' => 'google-client-id',
    'client_secret' => 'google-client-secret',
    'redirect_uri' => 'https://your-app.test/google-callback.php',
    'access_token' => $_SESSION['google_access_token'],
]);

$events = $calendar->driver('google')->listEvents([
    'maxResults' => 10,
    'singleEvents' => true,
    'orderBy' => 'startTime',
    'timeMin' => date('c'),
]);

Refresh an expired Google access token with the stored refresh token:

$newToken = $calendar->driver('google')->refreshAccessToken($storedRefreshToken);

// Save the new access token details for the user.
// Keep the old refresh token if Google does not return a new one.

Quick Create

$event = $calendar->driver('google')->quickCreate([
    'title' => 'Planning call',
    'start' => '2026-05-01 10:00',
    'end' => '2026-05-01 10:30',
    'timezone' => 'Asia/Kolkata',
    'description' => 'Discuss launch tasks',
    'attendees' => ['person@example.com'],
]);

$outlookEvent = $calendar->driver('outlook')->quickCreate([
    'title' => 'Planning call',
    'start' => '2026-05-01 10:00',
    'end' => '2026-05-01 10:30',
    'timezone' => 'Asia/Kolkata',
    'attendees' => ['person@example.com'],
]);

You can still call createEvent() directly with raw Google Calendar or Microsoft Graph event arrays when you need full provider control.

Online Meeting

$googleMeet = $calendar->driver('google')->createEventWithMeet([
    'title' => 'Demo call',
    'start' => '2026-05-01 15:00',
    'end' => '2026-05-01 15:30',
    'timezone' => 'Asia/Kolkata',
]);

$teamsMeeting = $calendar->driver('outlook')->createEventWithMeet([
    'title' => 'Demo call',
    'start' => '2026-05-01 15:00',
    'end' => '2026-05-01 15:30',
    'timezone' => 'Asia/Kolkata',
]);

List and Search

$events = $calendar->driver('google')->listNormalizedEvents([
    'maxResults' => 10,
    'singleEvents' => true,
    'orderBy' => 'startTime',
    'timeMin' => date('c'),
]);

$events = $calendar->driver('google')->eventsBetween(
    '2026-05-01 00:00',
    '2026-05-31 23:59',
    ['timezone' => 'Asia/Kolkata']
);

$events = $calendar->driver('google')->searchEvents('planning');

Normalized events return a common array shape:

[
    'id' => '...',
    'provider' => 'google',
    'title' => 'Planning call',
    'start' => '2026-05-01T10:00:00+05:30',
    'end' => '2026-05-01T10:30:00+05:30',
    'meeting_link' => 'https://...',
    'raw' => $providerEvent,
]

Check Availability

$busy = $calendar->driver('google')->checkAvailability([
    'timeMin' => '2026-05-01T09:00:00+05:30',
    'timeMax' => '2026-05-01T18:00:00+05:30',
]);

$schedule = $calendar->driver('outlook')->checkAvailability([
    'schedules' => ['person@example.com'],
    'startTime' => [
        'dateTime' => '2026-05-01T09:00:00',
        'timeZone' => 'Asia/Kolkata',
    ],
    'endTime' => [
        'dateTime' => '2026-05-01T18:00:00',
        'timeZone' => 'Asia/Kolkata',
    ],
]);

Development

composer install
composer check

chetansingh/calendar-manager 适用场景与选型建议

chetansingh/calendar-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 chetansingh/calendar-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 chetansingh/calendar-manager 我们能提供哪些服务?
定制开发 / 二次开发

基于 chetansingh/calendar-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 43
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-28