PHPackages                             tutu-ru/lib-msgraph-sdk - 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. tutu-ru/lib-msgraph-sdk

ActiveLibrary[API Development](/categories/api)

tutu-ru/lib-msgraph-sdk
=======================

The Microsoft Graph SDK for PHP

1.8.0(7y ago)033MITPHPPHP ^5.6 || ^7.0

Since Dec 15Pushed 7y ago5 watchersCompare

[ Source](https://github.com/tutu-ru/php-msgraph-sdk)[ Packagist](https://packagist.org/packages/tutu-ru/lib-msgraph-sdk)[ Docs](https://graph.microsoft.io/en-us/)[ RSS](/packages/tutu-ru-lib-msgraph-sdk/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (4)Versions (21)Used By (0)

Get started with the Microsoft Graph SDK for PHP
================================================

[](#get-started-with-the-microsoft-graph-sdk-for-php)

[![Build Status](https://camo.githubusercontent.com/ef27ad2349d87cda70d9c433d672da78dd082d86886531152a6304e58b757b9d/68747470733a2f2f7472617669732d63692e6f72672f6d6963726f736f667467726170682f6d7367726170682d73646b2d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/microsoftgraph/msgraph-sdk-php)[![Latest Stable Version](https://camo.githubusercontent.com/63ab915a25d54ca24c223837d19fdbf629f0ed30573495975abd00294e7d8093/68747470733a2f2f706f7365722e707567782e6f72672f6d6963726f736f66742f6d6963726f736f66742d67726170682f76657273696f6e)](https://packagist.org/packages/microsoft/microsoft-graph)

Get started with the PHP Connect Sample
---------------------------------------

[](#get-started-with-the-php-connect-sample)

If you want to play around with the PHP library, you can get up and running quickly with the [PHP Connect Sample](https://github.com/microsoftgraph/php-connect-sample). This sample will start you with a little Laravel project that helps you with registration, authentication, and making a simple call to the service.

Install the SDK
---------------

[](#install-the-sdk)

You can install the PHP SDK with Composer, either run `composer require microsoft/microsoft-graph`, or edit your `composer.json` file:

```
{
    "require": {
        "microsoft/microsoft-graph": "^1.5"
    }
}

```

Get started with Microsoft Graph
--------------------------------

[](#get-started-with-microsoft-graph)

### Register your application

[](#register-your-application)

Register your application to use the Microsoft Graph API by using one of the following supported authentication portals:

- [Microsoft Application Registration Portal](https://apps.dev.microsoft.com) (**Recommended**): Register a new application that authenticates using the v2.0 authentication endpoint. This endpoint authenticates both personal (Microsoft) and work or school (Azure Active Directory) accounts.
- [Microsoft Azure Active Directory](https://manage.windowsazure.com): Register a new application in your tenant's Active Directory to support work or school users for your tenant, or multiple tenants.

### Authenticate with the Microsoft Graph service

[](#authenticate-with-the-microsoft-graph-service)

The Microsoft Graph SDK for PHP does not include any default authentication implementations. The [`thephpleague/oauth2-client`](https://github.com/thephpleague/oauth2-client) library will handle the OAuth2 flow for you and provide a usable token for querying the Graph.

To authenticate as an application you can use the [Guzzle HTTP client](http://docs.guzzlephp.org/en/stable/), which comes preinstalled with this library, for example like this:

```
$guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token?api-version=1.0';
$token = json_decode($guzzle->post($url, [
    'form_params' => [
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'resource' => 'https://graph.microsoft.com/',
        'grant_type' => 'client_credentials',
    ],
])->getBody()->getContents());
$accessToken = $token->access_token;
```

For an integrated example on how to use Oauth2 in a Laravel application and use the Graph, see the [PHP Connect Sample](https://github.com/microsoftgraph/php-connect-sample).

### Call Microsoft Graph

[](#call-microsoft-graph)

The following is an example that shows how to call Microsoft Graph.

```
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;

class UsageExample
{
    public function run()
    {
        $accessToken = 'xxx';

        $graph = new Graph();
        $graph->setAccessToken($accessToken);

        $user = $graph->createRequest("GET", "/me")
                      ->setReturnType(Model\User::class)
                      ->execute();

        echo "Hello, I am $user->getGivenName() ";
    }
}
```

Develop
-------

[](#develop)

### Debug

[](#debug)

You can use the library with a proxy such as [Fiddler](http://www.telerik.com/fiddler) or [Charles Proxy](https://www.charlesproxy.com/) to debug requests and responses as they come across the wire. Set the proxy port on the Graph object like this:

```
$graph->setProxyPort("localhost:8888");
```

Then, open your proxy client to view the requests &amp; responses sent using the library.

[![Screenshot of Fiddler /me/sendmail request and response](https://github.com/microsoftgraph/msgraph-sdk-php/raw/master/docs/images/Fiddler.PNG)](https://github.com/microsoftgraph/msgraph-sdk-php/blob/master/docs/images/Fiddler.PNG)

This is especially helpful when the library does not return the results you expected to determine whether there are bugs in the API or this SDK. Therefore, you may be asked to provide this information when attempting to triage an issue you file.

### Run Tests

[](#run-tests)

Run

```
vendor/bin/phpunit --exclude-group functional
```

from the base directory.

*The set of functional tests are meant to be run against a test account. Currently, the tests to do not restore state of the account.*

Documentation and resources
---------------------------

[](#documentation-and-resources)

- [Documentation](https://github.com/microsoftgraph/msgraph-sdk-php/blob/master/docs/index.html)
- [Wiki](https://github.com/microsoftgraph/msgraph-sdk-php/wiki)
- [Examples](https://github.com/microsoftgraph/msgraph-sdk-php/wiki/Example-calls)
- [Microsoft Graph website](https://developer.microsoft.com/en-us/graph/)

Issues
------

[](#issues)

View or log issues on the [Issues](https://github.com/microsoftgraph/msgraph-sdk-php/issues) tab in the repo.

Contribute
----------

[](#contribute)

Please read our [Contributing](https://github.com/microsoftgraph/msgraph-sdk-php/blob/master/CONTRIBUTING.md) guidelines carefully for advice on how to contribute to this repo.

Copyright and license
---------------------

[](#copyright-and-license)

Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT [license](LICENSE).

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact  with any additional questions or comments.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~47 days

Total

15

Last Release

2695d ago

Major Versions

0.1.1 → 1.0.02017-05-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/f05979af988971530a44299e83c5f4e881c2d0abc6b60964abc7e72f6dd8c1d1?d=identicon)[alexkrass](/maintainers/alexkrass)

![](https://www.gravatar.com/avatar/a754a3e15bc08f072b98c18fa4ccbee774e47a44fecc5cb487fe2b95b2c4d969?d=identicon)[tutu-ru](/maintainers/tutu-ru)

---

Top Contributors

[![MIchaelMainer](https://avatars.githubusercontent.com/u/8527305?v=4)](https://github.com/MIchaelMainer "MIchaelMainer (20 commits)")[![AleksandrNikulin](https://avatars.githubusercontent.com/u/40687056?v=4)](https://github.com/AleksandrNikulin "AleksandrNikulin (8 commits)")[![curry684](https://avatars.githubusercontent.com/u/1455673?v=4)](https://github.com/curry684 "curry684 (8 commits)")[![Zombaya](https://avatars.githubusercontent.com/u/13340313?v=4)](https://github.com/Zombaya "Zombaya (6 commits)")[![dan-silver](https://avatars.githubusercontent.com/u/1266893?v=4)](https://github.com/dan-silver "dan-silver (3 commits)")[![noahheck](https://avatars.githubusercontent.com/u/4154306?v=4)](https://github.com/noahheck "noahheck (2 commits)")[![iampoul](https://avatars.githubusercontent.com/u/496452?v=4)](https://github.com/iampoul "iampoul (1 commits)")[![tdondich](https://avatars.githubusercontent.com/u/3330334?v=4)](https://github.com/tdondich "tdondich (1 commits)")[![anvanza](https://avatars.githubusercontent.com/u/2848347?v=4)](https://github.com/anvanza "anvanza (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tutu-ru-lib-msgraph-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/tutu-ru-lib-msgraph-sdk/health.svg)](https://phpackages.com/packages/tutu-ru-lib-msgraph-sdk)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.3M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1942.4k4](/packages/aimeos-prisma)

PHPackages © 2026

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