PHPackages                             grim-reapper/msgraph-php - 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. grim-reapper/msgraph-php

ActiveLibrary[API Development](/categories/api)

grim-reapper/msgraph-php
========================

A comprehensive PHP package for Microsoft Graph API integration with OAuth 2.0 authentication, OneDrive file management, and document conversion capabilities

1.0.0(7mo ago)01MITPHPPHP ^8.1

Since Sep 28Pushed 7mo agoCompare

[ Source](https://github.com/grim-reapper/msgraph-php)[ Packagist](https://packagist.org/packages/grim-reapper/msgraph-php)[ Docs](https://github.com/grim-reapper/msgraph-php)[ RSS](/packages/grim-reapper-msgraph-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (12)Versions (2)Used By (0)

Microsoft Graph PHP Package
===========================

[](#microsoft-graph-php-package)

[![Latest Version](https://camo.githubusercontent.com/70f8afb3b25129c8f4a753ae70d2e5bfdb7b3513c5d83a8951af11e25199be1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6772696d2d726561707065722f6d7367726170682d7068702e737667)](https://packagist.org/packages/grim-reapper/msgraph-php)[![PHP Version](https://camo.githubusercontent.com/a7bef3ad24bfccdbc6b0742332639e1313500e38ba67e8a47f9f18759967d714/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6772696d2d726561707065722f6d7367726170682d7068702e737667)](https://packagist.org/packages/grim-reapper/msgraph-php)[![Build Status](https://camo.githubusercontent.com/951de7f31d7bf2e8583300ee18e4db3dde3097dba9ebdb4ffa7287918d1fe9ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6772696d2d726561707065722f6d7367726170682d7068702f63692e796d6c)](https://github.com/grim-reapper/msgraph-php/actions)[![Code Coverage](https://camo.githubusercontent.com/036eeb969e4d147d303cdac52d725f7b48c6d638345514321185b67baf2be47f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6772696d2d726561707065722f6d7367726170682d706870)](https://codecov.io/gh/grim-reapper/msgraph-php)[![License](https://camo.githubusercontent.com/6db12223f468d829832294d50bc2763d353321cd481e208a1878a664dc53cfb9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6772696d2d726561707065722f6d7367726170682d7068702e737667)](https://packagist.org/packages/grim-reapper/msgraph-php)

A comprehensive and robust PHP package for integrating with Microsoft Graph API, providing seamless access to Microsoft 365 services including OneDrive, Outlook, Calendar, Teams, and more.

Features
--------

[](#features)

- 🚀 **OAuth 2.0 Authentication** - Secure authentication with Azure Active Directory
- 📁 **OneDrive Integration** - Complete file management capabilities
- 📄 **Document Conversion** - Convert documents (DOCX to PDF, etc.)
- 📧 **Email Operations** - Send, read, and manage emails
- 📅 **Calendar Management** - Create and manage events
- 👥 **User Management** - User profiles and presence
- 🔒 **Enterprise Security** - Production-ready security practices
- 🧪 **Comprehensive Testing** - Unit and integration tests
- 📚 **Rich Documentation** - Complete API documentation and examples

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Composer for dependency management
- Azure AD application for authentication

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

[](#installation)

```
composer require grim-reapper/msgraph-php
```

Quick Start
-----------

[](#quick-start)

### 1. Authentication Setup

[](#1-authentication-setup)

First, create an Azure AD application and obtain your credentials:

```
use GrimReapper\MsGraph\Authentication\AuthConfig;
use GrimReapper\MsGraph\Core\GraphClient;

$config = new AuthConfig([
    'clientId' => 'your-client-id',
    'clientSecret' => 'your-client-secret',
    'tenantId' => 'your-tenant-id',
    'redirectUri' => 'https://yourapp.com/callback'
]);

$graphClient = new GraphClient($config);
```

### 2. OneDrive Operations

[](#2-onedrive-operations)

```
use GrimReapper\MsGraph\Services\OneDriveService;

$oneDrive = new OneDriveService($graphClient);

// List files
$files = $oneDrive->listFiles('/');

// Upload a file
$oneDrive->uploadFile('/path/to/local/file.pdf', 'Documents/file.pdf');

// Download a file
$content = $oneDrive->downloadFile('/Documents/file.pdf');
```

### 3. Document Conversion

[](#3-document-conversion)

```
use GrimReapper\MsGraph\Services\DocumentService;

$documentService = new DocumentService($graphClient);

// Convert DOCX to PDF
$convertedContent = $documentService->convertDocument(
    '/Documents/document.docx',
    'pdf'
);
```

### 4. Email Operations

[](#4-email-operations)

```
use GrimReapper\MsGraph\Services\MailService;

$mailService = new MailService($graphClient);

// Send email
$mailService->sendEmail([
    'to' => 'recipient@example.com',
    'subject' => 'Test Email',
    'body' => 'This is a test email from Microsoft Graph PHP'
]);

// Read emails
$messages = $mailService->getMessages();
```

Documentation
-------------

[](#documentation)

- [API Documentation](docs/api/) - Complete API reference
- [Authentication Guide](docs/guides/authentication.md) - Setup OAuth 2.0
- [Examples](docs/examples/) - Code examples and use cases
- [Contributing](CONTRIBUTING.md) - Development guidelines

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

[](#configuration)

### Authentication Options

[](#authentication-options)

```
$config = new AuthConfig([
    'clientId' => 'your-client-id',
    'clientSecret' => 'your-client-secret',
    'tenantId' => 'your-tenant-id',
    'redirectUri' => 'https://yourapp.com/callback',
    'scopes' => ['https://graph.microsoft.com/.default'],
    'cache' => new FileCache(), // Optional: Custom cache implementation
    'logger' => new Logger(), // Optional: Custom logger
]);
```

### Advanced Configuration

[](#advanced-configuration)

```
// Custom HTTP client
$httpClient = new GuzzleHttp\Client([
    'timeout' => 30,
    'headers' => ['User-Agent' => 'MyApp/1.0']
]);

$graphClient = new GraphClient($config, $httpClient);
```

Services Overview
-----------------

[](#services-overview)

ServiceDescriptionKey Methods`OneDriveService`File management`uploadFile()`, `downloadFile()`, `listFiles()`, `deleteFile()``DocumentService`Document conversion`convertDocument()`, `getSupportedFormats()``MailService`Email operations`sendEmail()`, `getMessages()`, `getMessage()``CalendarService`Calendar management`createEvent()`, `getEvents()`, `updateEvent()``UserService`User management`getUser()`, `getUsers()`, `getUserPhoto()`Error Handling
--------------

[](#error-handling)

```
use GrimReapper\MsGraph\Exceptions\GraphException;
use GrimReapper\MsGraph\Exceptions\AuthenticationException;

try {
    $files = $oneDrive->listFiles('/');
} catch (AuthenticationException $e) {
    // Handle authentication errors
    echo "Authentication failed: " . $e->getMessage();
} catch (GraphException $e) {
    // Handle API errors
    echo "Graph API error: " . $e->getMessage();
} catch (Exception $e) {
    // Handle other errors
    echo "General error: " . $e->getMessage();
}
```

Testing
-------

[](#testing)

```
# Run all tests
composer test

# Run with coverage
composer test:coverage

# Run only unit tests
composer test -- --testsuite "Unit Tests"

# Run only integration tests
composer test -- --testsuite "Integration Tests"
```

Security
--------

[](#security)

This package implements security best practices:

- Secure token storage and refresh
- Input validation and sanitization
- Protection against common vulnerabilities
- HTTPS enforcement
- Rate limiting support

Contributing
------------

[](#contributing)

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Run tests (`composer test`)
4. Commit your changes (`git commit -m 'Add amazing feature'`)
5. Push to the branch (`git push origin feature/amazing-feature`)
6. Open a Pull Request

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Support
-------

[](#support)

- 📖 [Documentation](docs/)
- 🐛 [Issues](https://github.com/grim-reapper/msgraph-php/issues)
- 💬 [Discussions](https://github.com/grim-reapper/msgraph-php/discussions)
- 📧 [Email Support](mailto:support@grim-reapper.com)

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for a list of changes and version history.

---

Made with ❤️ by [Grim Reapper Corp](https://grim-reapper.com)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance62

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

232d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7252105628ffa6f064585370161626c7c72e68dd2e74ee66aa50d5894543c183?d=identicon)[webz2feel](/maintainers/webz2feel)

---

Top Contributors

[![grim-reapper](https://avatars.githubusercontent.com/u/7957389?v=4)](https://github.com/grim-reapper "grim-reapper (1 commits)")

---

Tags

phpapisdkoauth2microsoftazuregraphOneDriveOffice365

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/grim-reapper-msgraph-php/health.svg)

```
[![Health](https://phpackages.com/badges/grim-reapper-msgraph-php/health.svg)](https://phpackages.com/packages/grim-reapper-msgraph-php)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23914.2M16](/packages/hubspot-api-client)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[resend/resend-php

Resend PHP library.

574.7M21](/packages/resend-resend-php)

PHPackages © 2026

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