PHPackages                             krizalys/onedrive-php-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. krizalys/onedrive-php-sdk

ActiveLibrary[API Development](/categories/api)

krizalys/onedrive-php-sdk
=========================

OneDrive SDK for PHP.

3.2.0(3y ago)143404.3k↓39.7%69[19 issues](https://github.com/krizalys/onedrive-php-sdk/issues)[2 PRs](https://github.com/krizalys/onedrive-php-sdk/pulls)BSD-3-ClausePHPPHP ^7.3 | ^8.0CI failing

Since Nov 22Pushed 2y ago8 watchersCompare

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

READMEChangelogDependencies (7)Versions (26)Used By (0)

OneDrive SDK for PHP
====================

[](#onedrive-sdk-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/07d86e951b58a6ea6c7bdfaf0c53a70c3d06887a28f362e0d737966f0d3506fa/68747470733a2f2f706f7365722e707567782e6f72672f6b72697a616c79732f6f6e6564726976652d7068702d73646b2f762f737461626c65)](https://packagist.org/packages/krizalys/onedrive-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/529d17bc0ad33c887697aa83c0311a837882e9cab40d98b0e5ddd06ac51cba74/68747470733a2f2f706f7365722e707567782e6f72672f6b72697a616c79732f6f6e6564726976652d7068702d73646b2f642f746f74616c2e737667)](https://packagist.org/packages/krizalys/onedrive-php-sdk)[![Build Status](https://camo.githubusercontent.com/4091338cdcc73011feb1378320faf3986113d205b72968be8d28fb7c1a2eb7fd/68747470733a2f2f7472617669732d63692e6f72672f6b72697a616c79732f6f6e6564726976652d7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/krizalys/onedrive-php-sdk)[![Code Coverage](https://camo.githubusercontent.com/25e6b7986e4a0d40a17a0946215e3e62ac2db8d95a62ec8e8856454c7eb4639a/68747470733a2f2f636f6465636f762e696f2f67682f6b72697a616c79732f6f6e6564726976652d7068702d73646b2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/krizalys/onedrive-php-sdk)[![StyleCI](https://camo.githubusercontent.com/3c5a3cefd698a760a5bbea54d7a4def33d7ec8e7a4a535020f5c4e0de879ce63/68747470733a2f2f7374796c6563692e696f2f7265706f732f32333939343438392f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/23994489)

The **OneDrive SDK for PHP** is an open source library that allows [PHP](http://php.net/)applications to interact programmatically with the [OneDrive REST API](https://docs.microsoft.com/en-us/onedrive/developer/rest-api/?view=odsp-graph-online).

It supports operations such as creating, reading, updating, deleting (CRUD) files and folders, as well as moving or copying them to other folders.

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

[](#requirements)

Using the OneDrive SDK for PHP requires the following:

- [PHP](http://php.net/) 7.3 or newer ;
- [Composer](https://getcomposer.org/) or a manual install of the dependencies mentioned in `composer.json`.

### Testing

[](#testing)

Running its functional tests also require:

- A OneDrive web application configured with `http://localhost:7777/` as its redirect URI ;
- A WebDriver server, for example the [Selenium Server (Grid)](https://www.selenium.dev/downloads/) ;
- A Chrome browser &amp; ChromeDriver, and they must be usable by the WebDriver server.

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

[](#installation)

The recommended way to install OneDrive SDK for PHP is to install it using [Composer](https://getcomposer.org/):

```
composer require krizalys/onedrive-php-sdk
```

If you are not already using Composer in your PHP project, refer to [the Composer documentation](https://getcomposer.org/) to learn how to set it up.

Quick start
-----------

[](#quick-start)

To use the OneDrive SDK for PHP, you require a web application exposing a URL initiating the authorization flow. Typically, this URL, referred to as your web application's ***Redirect URI***, is a PHP script requesting an authorization token. This token is required whenever your web application interacts with your users' OneDrive contents and may be reused across multiple calls. An example of such a web application is our [functional test suite](https://github.com/krizalys/onedrive-php-sdk/tree/readme/test/functional).

You also require a OneDrive application. To register such an application, first [sign in to Microsoft Azure](https://login.microsoftonline.com/), then visit [App registrations](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade) and add a *registration* for your application. While registering your application, you need to set its *Redirect URI*, explained above. **We currently only support *Web* redirect URIs.**

Once created, your application is assigned an *Application (client) ID*, referred to as its ***Client ID***. In *Certificate &amp; secrets*, you also need to add at least one ***Client secret***. **Warning: *Client Secrets* are similar to passwords or private keys by allowing an application to identify as yours: therefore, *Client Secrets* should be kept private.**

Once you have a *Redirect URI*, a *Client ID*, and a *Client Secret*, your web application can start using the OneDrive SDK for PHP in three steps.

### Step 1: create your configuration

[](#step-1-create-your-configuration)

As you may need them from several scripts, we recommend saving your *Client ID*, *Client secret* and *Redirect URI* in a configuration file, for example:

#### `config.php`

[](#configphp)

```
