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

ActiveLibrary

pdjshog/onedrive-php-sdk
========================

OneDrive SDK for PHP. (forked/updated for guzzle 7.2)

2.6.0(6y ago)041BSD-3-ClausePHPPHP ^5.6 || ^7.0

Since Nov 22Pushed 3y agoCompare

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

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

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

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

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/) 1.0.0-alpha10 or newer
- Basic PHP knowledge

### Testing

[](#testing)

For development, you also require:

- A OneDrive web application configured with `http://localhost:7777/` as its redirect URI
- A WebDriver server, for example the [Selenium's Java standalone server](http://selenium-release.storage.googleapis.com/index.html)
- 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 pdjshog/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 first.

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

[](#quick-start)

When using OneDrive SDK for PHP, you are assumed to have an application exposing a URL receiving user authentication data from OneDrive. Typically, this URL, referred to as your application's ***Redirect URI***, is a PHP script accepting this data to expose functionality interacting with your users' OneDrive contents. An example of such an application is our [functional test suite](https://github.com/krizalys/onedrive-php-sdk/tree/readme/test/functional).

You also need to register a OneDrive application. To do this, 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 are given the option 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***, and in *Certificate &amp; secrets*, you need to add at least one ***Client secret***. **Warning: *Client Secrets* are similar to passwords or private keys, they allow applications to identify as yours: they should be handled securely and not be disclosed to third-parties.**

Once you have a *Redirect URI*, a *Client ID*, and a *Client Secret*, your 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:

```
