PHPackages                             leapt/flysystem-onedrive - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. leapt/flysystem-onedrive

ActiveLibrary[File &amp; Storage](/categories/file-storage)

leapt/flysystem-onedrive
========================

Flysystem Adapter for the OneDrive API

v1.1.0(1y ago)36.4k↓33.3%[1 issues](https://github.com/leapt/flysystem-onedrive/issues)MITPHPPHP ^8.3CI passing

Since Aug 29Pushed 10mo agoCompare

[ Source](https://github.com/leapt/flysystem-onedrive)[ Packagist](https://packagist.org/packages/leapt/flysystem-onedrive)[ Docs](https://github.com/leapt/flysystem-onedrive)[ RSS](/packages/leapt-flysystem-onedrive/feed)WikiDiscussions 1.x Synced 2d ago

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

Flysystem adapter for the Microsoft OneDrive API
================================================

[](#flysystem-adapter-for-the-microsoft-onedrive-api)

[![Package version](https://camo.githubusercontent.com/64c60ce43858c6b6f80a9745799c69abb4338bffa7d2f953fd5c0577d5fd9432/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c656170742f666c7973797374656d2d6f6e6564726976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leapt/flysystem-onedrive)[![Build Status](https://camo.githubusercontent.com/916b5c4919c009403284dbcb8e634a82d4b23fe5e3293908b573dca4c074ab51/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c656170742f666c7973797374656d2d6f6e6564726976652f636f6e74696e756f75732d696e746567726174696f6e2e796d6c3f6272616e63683d312e78267374796c653d666c61742d737175617265)](https://github.com/leapt/flysystem-onedrive/actions?query=workflow%3A%22Continuous+Integration%22)[![PHP Version](https://camo.githubusercontent.com/95903eedb9d0b73fd11870f6597320ad60fd36f6a4ee1ca679cdca9d5c57ee38/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c656170742f666c7973797374656d2d6f6e6564726976652e7376673f6272616e63683d312e78267374796c653d666c61742d737175617265)](https://travis-ci.org/leapt/flysystem-onedrive?branch=1.x)[![License](https://camo.githubusercontent.com/10e85a5778fe7601504a17ecd18dfa7097f473186b0f947bc10db2d3e4f530e4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d7265642e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Code coverage](https://camo.githubusercontent.com/0586ad095dc5ebf1c59659b9f3ea89f1d7ec87ff8605dc0769363ec199ef61b4/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6c656170742f666c7973797374656d2d6f6e6564726976653f7374796c653d666c61742d737175617265)](https://codecov.io/gh/leapt/flysystem-onedrive/branch/1.x)

This package contains a [Flysystem](https://flysystem.thephpleague.com/) adapter for OneDrive. Under the hood, the [Microsoft Graph SDK](https://github.com/microsoftgraph/msgraph-sdk-php) is used.

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

[](#installation)

This package requires PHP 8.3+ and Flysystem v3.

You can install the package using composer:

```
composer require leapt/flysystem-onedrive
```

Usage
-----

[](#usage)

The first thing you need to do is get an authorization token for the Microsoft Graph API. For that you need to create an app on the [Microsoft Azure Portal](https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/app-registration?view=odsp-graph-online).

```
use League\Flysystem\Filesystem;
use Leapt\FlysystemOneDrive\OneDriveAdapter;
use Microsoft\Graph\Graph;

$graph = new Graph();
$graph->setAccessToken('EwBIA8l6BAAU7p9QDpi...');

$adapter = new OneDriveAdapter($graph);
$filesystem = new Filesystem($adapter);

// Or to use the approot endpoint:
$adapter = new OneDriveAdapter($graph, 'special/approot');
```

### Retrieve a bearer token

[](#retrieve-a-bearer-token)

If you are looking for a way to retrieve a bearer token, here are two examples:

- first example using [Symfony HTTP Client](https://symfony.com/doc/current/http_client.html)
- second example using [Guzzle](https://github.com/guzzle/guzzle), which is already included as a dependency from Microsoft Graph SDK

#### Using Symfony HTTP Client

[](#using-symfony-http-client)

```
$tenantId = 'your tenant id';
$clientId = 'your client id';
$clientSecret = 'your client secret';
$scope = 'https://graph.microsoft.com/.default';
$oauthUrl = sprintf('https://login.microsoftonline.com/%s/oauth2/v2.0/token', $tenantId);

$client = \Symfony\Component\HttpClient\HttpClient::create();
$response = $client->request('GET', $oauthUrl, ['body' => [
    'client_id'     => $clientId,
    'scope'         => $scope,
    'grant_type'    => 'client_credentials',
    'client_secret' => $clientSecret,
]]);
$bearerToken = $response->toArray()['access_token'];
```

#### Using Guzzle

[](#using-guzzle)

```
$tenantId = 'your tenant id';
$clientId = 'your client id';
$clientSecret = 'your client secret';
$scope = 'https://graph.microsoft.com/.default';
$oauthUrl = sprintf('https://login.microsoftonline.com/%s/oauth2/v2.0/token', $tenantId);

$client = new \GuzzleHttp\Client();
$response = $client->request('POST', $oauthUrl, ['form_params' => [
    'client_id'     => $clientId,
    'scope'         => $scope,
    'grant_type'    => 'client_credentials',
    'client_secret' => $clientSecret,
]]);
$bearerToken = json_decode((string) $response->getBody(), true)['access_token'];
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG-1.x.md) for more information what has changed recently.

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

[](#contributing)

Feel free to contribute, like sending [pull requests](https://github.com/leapt/flysystem-onedrive/pulls) to add features/tests or [creating issues](https://github.com/leapt/flysystem-onedrive/issues) :)

Note there are a few helpers to maintain code quality, that you can run using these commands:

```
composer cs:dry # Code style check
composer phpstan # Static analysis
vendor/bin/phpunit # Run tests
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

History
-------

[](#history)

This bundle is a maintained fork of the packages [nicolasbeauvais](https://github.com/nicolasbeauvais/flysystem-onedrive)and [hevelius](https://github.com/hevelius/flysystem-onedrive).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance42

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 57.7% 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 ~366 days

Total

4

Last Release

307d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.1.0PHP ^8.3

### Community

Maintainers

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

---

Top Contributors

[![jmsche](https://avatars.githubusercontent.com/u/3929498?v=4)](https://github.com/jmsche "jmsche (15 commits)")[![hevelius](https://avatars.githubusercontent.com/u/49342144?v=4)](https://github.com/hevelius "hevelius (9 commits)")[![nicolasbeauvais](https://avatars.githubusercontent.com/u/2951704?v=4)](https://github.com/nicolasbeauvais "nicolasbeauvais (2 commits)")

---

Tags

apiFlysystemOneDriveflysystem-onedrive

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/leapt-flysystem-onedrive/health.svg)

```
[![Health](https://phpackages.com/badges/leapt-flysystem-onedrive/health.svg)](https://phpackages.com/packages/leapt-flysystem-onedrive)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[justus/flysystem-onedrive

A flysystem driver for OneDrive that uses the Microsoft Graph API

49142.4k](/packages/justus-flysystem-onedrive)[spatie/flysystem-dropbox

Flysystem Adapter for the Dropbox v2 API

3735.0M83](/packages/spatie-flysystem-dropbox)[shitware-ltd/flysystem-msgraph

A Flysystem 3.0 adapter for Sharepoint 365 / OneDrive using Microsoft Graph API with support for uploading large files

19466.1k4](/packages/shitware-ltd-flysystem-msgraph)[jacekbarecki/flysystem-onedrive

OneDrive adapter for the flysystem filesystem abstraction library

2431.0k](/packages/jacekbarecki-flysystem-onedrive)[mhetreramesh/flysystem-backblaze

Backblaze adapter for the flysystem filesystem abstraction library

63148.9k9](/packages/mhetreramesh-flysystem-backblaze)

PHPackages © 2026

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