PHPackages                             tarask/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. [API Development](/categories/api)
4. /
5. tarask/onedrive

ActiveLibrary[API Development](/categories/api)

tarask/onedrive
===============

Microsoft Graph Api - OneDrive for PHP

v1.1(7y ago)101.7k3[4 issues](https://github.com/calebdevelop/onedrive-api/issues)MITPHPPHP ^5.6 || ^7.0CI failing

Since Mar 20Pushed 6y ago2 watchersCompare

[ Source](https://github.com/calebdevelop/onedrive-api)[ Packagist](https://packagist.org/packages/tarask/onedrive)[ Docs](https://github.com/calebdevelop/onedrive-api)[ RSS](/packages/tarask-onedrive/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

One Drive Api for PHP
=====================

[](#one-drive-api-for-php)

##### The OneDrive REST API Official Documentation

[](#the-onedrive-rest-api-official-documentation)

##### Installation

[](#installation)

`$ composer require tarask/onedrive`

#### Generate token

[](#generate-token)

##### Get an Authorization code :

[](#get-an-authorization-code-)

```
require __DIR__.'/vendor/autoload.php';

use Tsk\OneDrive\Services\OneDriveService;
use Tsk\OneDrive\Client;

$client = new Client();
$client->setClientId('xxxxxxxx');
$client->setClientSecret('xxxxxxxx');
$client->setRedirectUri('http://localhost');
$client->setScopes([
    OneDriveService::ONEDRIVE_OFFLINE_ACCESS,
    OneDriveService::ONEDRIVE_FILE_READ,
    OneDriveService::ONEDRIVE_FILE_READ_ALL,
    OneDriveService::ONEDRIVE_FILE_READ_WRITE,
    OneDriveService::ONEDRIVE_FILE_READ_WRITE_ALL
]);
$authUrl = $client->createAuthUrl();

echo $authUrl;

```

Go to the browser and enter the generated url.
After authentication, you will be redirected to `http://localhost?code=xxxxxxx`

##### Redeem the code for access tokens :

[](#redeem-the-code-for-access-tokens-)

After getting the `code` value, you can recover your access token with `$client->fetchAccessTokenWithAuthCode($_GET['code'])`.

```
$token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
file_put_contents(__DIR__.'/token.json', \json_encode($token));

```

##### Upload large files

[](#upload-large-files)

```
$token = file_get_contents(__DIR__.'/token.json');
$client->setAccessToken($token);

$file = '/path/to/the/file.docx';

$handle   = fopen($file, 'rb');
$fileSize = filesize($file);
$chunkSize = 1024*1024;

$media = new MediaFileUpload($client, 'filename.docx', 'folderId', true, $chunkSize);
$media->setFileSize($fileSize);

$res = null;
while (!feof($handle)) {
    $bytes = fread($handle, $chunkSize);
    $res = $media->nextChunk($bytes);
}

echo 'FileId : ' . $res['id'];
print_r($res)

```

##### Create folder

[](#create-folder)

```
$service = new OneDriveService($client);
$service->items->createFolder("folder_name");

```

On this sample, `folder_name` is create in root folder. You can also create a subdirectory by adding folderId as a second parameter.

```
$service->items->createFolder("folder_name", "parent_folder_id");

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

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

Total

2

Last Release

2633d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8330513?v=4)[Caleb RAJAONARY](/maintainers/calebdevelop)[@calebdevelop](https://github.com/calebdevelop)

---

Top Contributors

[![calebdevelop](https://avatars.githubusercontent.com/u/8330513?v=4)](https://github.com/calebdevelop "calebdevelop (47 commits)")

---

Tags

Microsoft graphOneDrive apiOneDrive Rest api

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[sylius/sylius

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

8.5k5.9M724](/packages/sylius-sylius)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M552](/packages/shopware-core)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M497](/packages/pimcore-pimcore)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k12](/packages/2lenet-crudit-bundle)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)

PHPackages © 2026

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