fungio/google-calendar-bundle

Provides a google calendar integration for your Symfony 3 Project.

Installs: 41 709

Dependents: 0

Suggesters: 0

Security: 0

Stars: 10

Watchers: 2

Forks: 6

Open Issues: 0

Type:symfony-bundle

dev-master / 4.3.x-dev 2020-06-11 14:13 UTC

This package is auto-updated.

Last update: 2024-11-11 23:12:57 UTC


README

This bundle use Google API for list, create, or update events in Google Calendar.

Please feel free to contribute, to fork, to send merge request and to create ticket.

Requirement

Create a API account

Go to the developers console : https://console.developers.google.com

Create an oauth ID. Do not forget the redirect Uri.

Click on "Download JSON" to get your client_secret.json

Installation

Step 1: Install GoogleCalendarBundle

Run

composer require fungio/google-calendar-bundle:dev-master

Step 2: Enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Fungio\GoogleCalendarBundle\FungioGoogleCalendarBundle()
    ];
}

Step 3: Configuration

Copy your client_secret.json file for example in app/Resources/GoogleCalendarBundle/client_secret.json

# app/config/parameters.yml

fungio_google_calendar:
    google_calendar:
        application_name: "Google Calendar"
        credentials_path: "%kernel.root_dir%/.credentials/calendar.json"
        client_secret_path: "%kernel.root_dir%/Resources/GoogleCalendarBundle/client_secret.json"

Example

<?php
// in a controller
$request = $this->get('request_stack')->getMasterRequest();

$googleCalendar = $this->get('fungio.google_calendar');
$googleCalendar->setRedirectUri($redirectUri);

if ($request->query->has('code') && $request->get('code')) {
    $client = $googleCalendar->getClient($request->get('code'));
} else {
    $client = $googleCalendar->getClient();
}

if (is_string($client)) {
    return new RedirectResponse($client);
}

$events = $googleCalendar->getEventsForDate('primary', new \DateTime('now');