PHPackages                             totalcrm/microsoft-graph-bundle - 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. [API Development](/categories/api)
4. /
5. totalcrm/microsoft-graph-bundle

ActiveSymfony-bundle[API Development](/categories/api)

totalcrm/microsoft-graph-bundle
===============================

Symfony bundle for API MicrosoftGraph

1.0.5(4y ago)22642MITPHPPHP &gt;=7.4.0

Since Dec 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/totalcrm/microsoft-graph-bundle)[ Packagist](https://packagist.org/packages/totalcrm/microsoft-graph-bundle)[ Docs](https://github.com/totalcrm/microsoft-graph-bundle)[ RSS](/packages/totalcrm-microsoft-graph-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (11)Versions (7)Used By (0)

TotalCRM MicrosoftGraphBundle
=============================

[](#totalcrm-microsoftgraphbundle)

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

[](#installation)

### Add MicrosoftGraphBundle to your project

[](#add-microsoftgraphbundle-to-your-project)

The recommended way to install the bundle is through Composer.

```
$ composer require 'totalcrm/microsoft-graph-bundle'
```

Symfony 3: add MicrosoftGraphBundle in AppKernel.php registerBundles()

```
$bundles = [
    ...,
    New TotalCRM\MicrosoftGraph\MicrosoftGraphBundle(),
];
```

Symfony 4 and up: add MicrosoftGraphBundle in bundles.php

```
return [
    ...,
    TotalCRM\MicrosoftGraph\MicrosoftGraphBundle::class => ['all' => true],
];
```

Configuration
-------------

[](#configuration)

You have to configure your api.

Symfony 3: add to config.yml

Symfony 4 and up: create config/packages/microsoft\_graph.yaml

```
microsoft_graph:
    client_id: "%env(MS_GRAPH_CLIENT_ID)%"
    client_secret: "%env(MS_GRAPH_CLIENT_SECRET)%"
    tenant_id: "%env(MS_GRAPH_TENANT_ID)%"
    contact_folder: "%env(MS_GRAPH_CONTACT_FOLDER)%"
    redirect_uri: "app_dashboard"
    homepage_route: "app_dashboard"
    prefer_time_zone: "%env(MS_GRAPH_TIMEZONE_UTC)%"
    version: "1.0"
    scopes:  # see more details https://developer.microsoft.com/en-us/graph/docs/authorization/permission_scopes
        - openid
        - offline_access
        - Contacts.Read
        - Contacts.ReadWrite
        - Contacts.ReadWrite.Shared
        - Calendars.Read
        - Calendars.Read.Shared
        - Calendars.ReadWrite
        - Tasks.ReadWrite
        ...
```

Get token from Office 365 | API Graph
=====================================

[](#get-token-from-office-365--api-graph)

```
    /** @var MicrosoftGraphClient $graphClient */
    $graphClient = $container->get('microsoft_graph.client');

    try {
        /* if you have a refresh token then  the token will refresh */
        $graphClient->getNewToken();
    } catch(\Exception $ex) {
        /* return url by Authorization */

        $url = $graphClient->redirect();

        /*
        Follow the link $url and login in to Microsoft Office 365 Service
        After successful authorization, you should be redirected to the redirect_uri page with the code parameter, which you need to save
        See set token Office 365 auth and cached
        */
    }
```

Set token Office 365 auth and cached
====================================

[](#set-token-office-365-auth-and-cached)

```
    /** @var MicrosoftGraphClient $graphClient */
    $graphClient = $container->get('microsoft_graph.client');
    $authorizationCode = "0.AQUAIIWUa9rYQEKaSsxrxOyxTP-AiocQKThAr3_TKz.......";

    try {
        $this->graphClient->setAuthorizationCode($authorizationCode);
    } catch (\Exception $exception) {
        if ($exception->getMessage() === 'invalid_grant') {
            /*
            OAuth2 Authorization code was already redeemed
            Please retry with a new valid code or use an existing refresh token
            */
        } else {
            /*
            Authorization code save error
            Please retry with a new valid code or use an existing refresh token
            */
        }
    }
```

Example get contacts in folder
==============================

[](#example-get-contacts-in-folder)

```
    /** @var MicrosoftGraphContactManager $contactManager */
    $contactManager = $container->get('microsoft_graph.contact_manager');

    //Get Contacts by Folder
    /** @var Microsoft\Graph\Model\Contact[] $folders */
    $folders = $contactManager->getContactFolders();
    dump($contacts);

    foreach ($folders as $folder) {
        /** @var Microsoft\Graph\Model\Contact[] $contacts */
        $contacts = $contactManager->getContacts($folder->getId());
        dump($contacts);
    }

    //Get All Contacts
    /** @var Microsoft\Graph\Model\Contact[] $contacts */
    $contacts = $contactManager->getContacts();
    dump($contacts);
```

Example get contact by id
=========================

[](#example-get-contact-by-id)

```
    $id = '...';
    $contact = $contactManager->getContact($id);
    dump($contacts);
```

Create an contact
=================

[](#create-an-contact)

```
    /** @var Microsoft\Graph\Model\PhysicalAddress $businessAddress */
    $businessAddress = new Model\PhysicalAddress();
    $businessAddress
        ->setPostalCode('PostalCode')
        ->setCity('City')
        ->setState('State')
        ->setStreet('Street')
        ->setCountryOrRegion('Country')
    ;

    /** @var Microsoft\Graph\Model\EmailAddress $emailAddress */
    $emailAddress = new EmailAddress();
    $emailAddress
        ->setName('DisplayName')
        ->setAddress('email@gmail.com')
    ;

    /** @var Microsoft\Graph\Model\Contact $newContact */
    $newContact = new Model\Contact();
    $newContact
        ->setNickName('NickName')
        ->setDisplayName('DisplayName')
        ->setMiddleName('MiddleName')
        ->setGivenName('GivenName')
        ->setBusinessAddress($businessAddress)
        ->setEmailAddresses($emailAddress)
        ...
    ;

    $contact = $contactManager->addContact($newContact);
    dump($contact);
```

Example get events from outlook calendar
========================================

[](#example-get-events-from-outlook-calendar)

```
// Get calendar service
    $calendarManager = $this->get('microsoft_graph.calendar');

//Get a collection of Microsoft\Graph\Model\Event
    $startTime = new DateTime("first day of this month");
    $endTime = new DateTime("first day of next month");

    $events = $calendarManager->getEvents($startTime,$endTime);

//Get a  Microsoft\Graph\Model\Event
    $id='...';
    $event = $calendarManager->getEvent($id);

```

Create an event
===============

[](#create-an-event)

```
//  create Microsoft\Graph\Model\Event and set properties
    $newEvent = new Microsoft\Graph\Model\Event();
    $start = $calendar->getDateTimeTimeZone(new \DateTime('Now next minute'));
    $end = $calendar->getDateTimeTimeZone(new \DateTime('Now next hour'));

    $newEvent->setSubject('Controller Test Token');
    $newEvent->setStart($start);
    $newEvent->setEnd( $end);

    $event= $calendarManager->addEvent( $newEvent);

    dump($event);
```

Update an event
===============

[](#update-an-event)

```
    $id = '...';
    $updateEvent = new Microsoft\Graph\Model\Event();
    $updateEvent->setId($id);
    $updateEvent->setSubject("I Forgot The Eggs!");
    $event = $calendarManager->updateEvent($updateEvent);
```

Delete an event
===============

[](#delete-an-event)

```
    $id='...';
    $response = $calendar->deleteEvent($id);
    dump($response->getStatus()==204 ? "Event deleted" : $response);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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 ~34 days

Total

5

Last Release

1490d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15926848?v=4)[TotalCRM](/maintainers/TotalCRM)[@totalcrm](https://github.com/totalcrm)

---

Top Contributors

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

---

Tags

bundlecalendarcontactsmicrosoftgraphsymfonysymfony-bundlesymfonybundlemicrosoftcalendarcontactsmicrosoftgraphoffice-365

### Embed Badge

![Health badge](/badges/totalcrm-microsoft-graph-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/totalcrm-microsoft-graph-bundle/health.svg)](https://phpackages.com/packages/totalcrm-microsoft-graph-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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