Download the PHP package krizalys/onedrive-php-sdk without Composer
On this page you can find all versions of the php package krizalys/onedrive-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package onedrive-php-sdk
OneDrive SDK for PHP
The OneDrive SDK for PHP is an open source library that allows PHP applications to interact programmatically with the OneDrive REST API.
It supports operations such as creating, reading, updating, deleting (CRUD) files and folders, as well as moving or copying them to other folders.
Requirements
Using the OneDrive SDK for PHP requires the following:
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) ;
- A Chrome browser & ChromeDriver, and they must be usable by the WebDriver server.
Installation
The recommended way to install OneDrive SDK for PHP is to install it using Composer:
If you are not already using Composer in your PHP project, refer to the Composer documentation to learn how to set it up.
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.
You also require a OneDrive application. To register such an application, first sign in to Microsoft Azure, then visit App registrations 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 & 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
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
Step 2: direct your users to the sign in page
This script is responsible for, given a set of privileges, fetching a log in URL from the OneDrive API. It needs to direct users to this URL to initiate their log in and privilege granting process. The script should look like this:
index.php
Step 3: get an OAuth access token
After the users follow this URL, they are required to sign into their Microsoft account, and they are asked whether they agree to allow your web application to access their OneDrive account.
If they do, they are redirected to your Redirect URI and a code
is passed in
the query string of this URL. The script at this URL essentially:
- Instantiates a
Client
from your configuration and the state from previous instantiations ; - Obtains an OAuth access token using
Client::obtainAccessToken()
, passing it thecode
received ; - Starts interacting with the files and folders stored in their OneDrive
account, or delegates this responsibility to other scripts which in turn may
spawn other
Client
instances from the same state.
It typically looks like this (replace /path/to
by the appropriate values):
redirect.php
For details about classes and methods available, see the API reference or the project page on Krizalys.
Versioning
OneDrive SDK for PHP adheres to Semantic Versioning: we are committed not to introduce breaking changes to the public API without incrementing the major version number. We also try to document such changes in the changelog.
However, we only consider symbols marked with the @api
annotation to be
part of the public API and subject to Semantic Versioning requirements. Other
symbols are considered internal and may change or get removed without a major
version increment. To avoid breaking changes, use only symbols from the public
API in your code.
Testing
To run the functional test suite:
- Set your application configuration at
test/functional/config.php
; -
Run your WebDriver server, for example:
-
Run the functional test suite (it assumes that WebDriver listening on port 4444):
- Repeat step 3 as needed.
License
The OneDrive SDK for PHP is licensed under the 3-Clause BSD License.
Credits
The OneDrive SDK for PHP is developed and maintained by Christophe Vidal.
All versions of onedrive-php-sdk with dependencies
guzzlehttp/guzzle Version >=6.3.3
guzzlehttp/psr7 Version ^1.7 | ^2.4
microsoft/microsoft-graph Version ^1.7.0