PHPackages                             appopcen/php-spo - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. appopcen/php-spo

ActiveLibrary[HTTP &amp; Networking](/categories/http)

appopcen/php-spo
================

Fork from vgrem/php-spo

v2.2.3(7y ago)0595LGPL-3.0+PHPPHP &gt;=5.4

Since Apr 20Pushed 7y agoCompare

[ Source](https://github.com/appopcen/phpSPO)[ Packagist](https://packagist.org/packages/appopcen/php-spo)[ RSS](/packages/appopcen-php-spo/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (7)Used By (0)

### About

[](#about)

The library provides a Office 365 REST client for PHP applications. It allows to performs CRUD operations against Office 365 resources via an REST/OData based API.

#### The list of supported Office 365 REST APIs:

[](#the-list-of-supported-office-365-rest-apis)

- [SharePoint REST API](https://msdn.microsoft.com/en-us/library/office/jj860569.aspx) (*supported* versions: [SharePoint 2013](https://msdn.microsoft.com/library/office/jj860569(v=office.15).aspx), SharePoint 2016, SharePoint Online and OneDrive for Business)
- [Outlook REST API](https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api#DefineOutlookRESTAPI)
    - [Outlook Contacts REST API](https://msdn.microsoft.com/en-us/office/office365/api/contacts-rest-operations)
    - [Outlook Calendar REST API](https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations)
    - [Outlook Mail REST API](https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations)
    - OneNote REST API

### Status

[](#status)

[![Total Downloads](https://camo.githubusercontent.com/4f74786c79232289453faf904bd07f3fcb10bc2c2f27906c174044ef2e8f33f9/68747470733a2f2f706f7365722e707567782e6f72672f766772656d2f7068702d73706f2f646f776e6c6f616473)](https://packagist.org/packages/vgrem/php-spo)[![Latest Stable Version](https://camo.githubusercontent.com/3ac3b7d5434e64857bdd1e5da1c040b31ccb2aadc377595ebabe27d296776758/68747470733a2f2f706f7365722e707567782e6f72672f766772656d2f7068702d73706f2f762f737461626c65)](https://packagist.org/packages/vgrem/php-spo)[![Build Status](https://camo.githubusercontent.com/ca33db59d17d6e2341e12302be24726a5009fde195077ae382630d1dcbb69d6f/68747470733a2f2f7472617669732d63692e6f72672f766772656d2f70687053504f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vgrem/phpSPO)[![License](https://camo.githubusercontent.com/aa78805d094b21b09a8464ff247d113e39cc46937b000827301ef03d5fef1c12/68747470733a2f2f706f7365722e707567782e6f72672f766772656d2f7068702d73706f2f6c6963656e7365)](https://packagist.org/packages/vgrem/php-spo)

[![PayPal](https://camo.githubusercontent.com/e1ff554a09e8e92bef25abc553ff05b88f45afd695877cf12f3a46558ef65b2e/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=J99W9EM829BQC)

### Installation

[](#installation)

You can use **Composer** or simply **Download the Release**

#### Composer

[](#composer)

The preferred method is via [composer](https://getcomposer.org). Follow the [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

```
composer require vgrem/php-spo:dev-master -n --no-progress
```

Finally, be sure to include the autoloader:

```
require_once '/path/to/your-project/vendor/autoload.php';
```

### PHP version

[](#php-version)

- [PHP 5.4 or later](https://secure.php.net/)

### API

[](#api)

- PHP:cURL underlying library is used to perform HTTP requests
- `ClientContext` - represents a SharePoint client context to performs CRUD operations against SharePoint resources via SharePoint Online REST API
- `OutlookClient` - represents a client context to performs CRUD operations against Office resources such as Outlook resources
- `ClientRequest` - represents a client request (more low level compared to `ClientContext`) to to performs CRUD operations against SharePoint resources via SharePoint Online REST API
- `AuthenticationContext` - represents an object that provides credentials to access SharePoint Online resources.
- `NetworkCredentialContext` - provides credentials for password-based authentication schemes such as Basic.

There are **two** approaches available to perform REST based queries:

- via `ClientRequest` class where you need to construct REST queries by specifying endpoint url, headers if required and payload (low level approach), see [renameFolder.php](https://github.com/vgrem/phpSPO/blob/master/examples/renameFolder.php) for a more details
- via `ClientContext` class where you target client object resources such as Web, ListItem and etc., see [list\_examples.php](https://github.com/vgrem/phpSPO/blob/master/examples/list_examples.php) for a more details

### Usage

[](#usage)

#### Using SharePoint REST API

[](#using-sharepoint-rest-api)

The following examples demonstrates how to perform basic CRUD operations against **SharePoint** list item resources.

Example 1. How to read SharePoint list items

```
$authCtx = new AuthenticationContext($Url);
$authCtx->acquireTokenForUser($UserName,$Password); //authenticate

$ctx = new ClientContext($Url,$authCtx); //initialize REST client
$web = $ctx->getWeb();
$list = $web->getLists()->getByTitle($listTitle); //init List resource
$items = $list->getItems();  //prepare a query to retrieve from the
$ctx->load($items);  //save a query to retrieve list items from the server
$ctx->executeQuery(); //submit query to SharePoint Online REST service
foreach( $items->getData() as $item ) {
    print "Task: '{$item->Title}'\r\n";
}
```

Example 2. How to create SharePoint list item:

```
$listTitle = 'Tasks';
$list = $ctx->getWeb()->getLists()->getByTitle($listTitle);
$itemProperties = array('Title' => 'Order Approval', 'Body' => 'Order approval task','__metadata' => array('type' => 'SP.Data.TasksListItem'));
$item = $list->addItem($itemProperties);
$ctx->executeQuery();
print "Task '{$item->Title}' has been created.\r\n";
```

Example 3. How to delete a SharePoint list item:

```
$listTitle = 'Tasks';
$itemToDeleteId = 1;
$list = $ctx->getWeb()->getLists()->getByTitle($listTitle);
$listItem = $list->getItemById($itemToDeleteId);
$listItem->deleteObject();
$ctx->executeQuery();
```

Example 4. How to update SharePoint list item:

```
$listTitle = 'Tasks';
$itemToUpdateId = 1;
$list = $ctx->getWeb()->getLists()->getByTitle($listTitle);
$listItem = $list->getItemById($itemId);
$listItem->setProperty('PercentComplete',1);
$listItem->update();
$ctx->executeQuery();
```

#### Using Outlook REST API

[](#using-outlook-rest-api)

The following examples demonstrates how to read, create and send messages via Outlook Mail API.

Example 1. How to create a draft message

```
$authCtx = new NetworkCredentialContext($UserName,$Password); //using Basic Auth scheme (for v1 API only)
$ctx = new OutlookClient($authCtx); //initialize OutlookServices client
$message = $ctx->getMe()->getMessages()->createMessage(); //create a Message resource
//set Message properties
$message->Subject = "--subject--";
$message->Body = new ItemBody(BodyType::Text,"--Content goes here--");
$message->ToRecipients = array(
     new Recipient(new EmailAddress("Jon Doe","jdoe@contoso.onmicrosoft.com"))
);
$ctx->executeQuery();
```

Example 2. How to get messages

```
$authCtx = new NetworkCredentialContext($UserName,$Password); //using Basic Auth scheme (for v1 API only)
$ctx = new OutlookClient($authCtx); //initialize OutlookServices client
$messages = $ctx->getMe()->getMessages();
$ctx->load($messages);
$ctx->executeQuery();
//print messages subjects
foreach ($messages->getData() as $curMessage){
   print $curMessage->Subject;
}
```

Example 3. How to send a message

```
$authCtx = new NetworkCredentialContext($UserName,$Password); //using Basic Auth scheme (for v1 API only)
$ctx = new OutlookClient($authCtx); //initialize OutlookServices client
$message = $ctx->getMe()->getMessages()->createMessage(); //create a Message resource
//set Message properties
$message->Subject = "--subject--";
$message->Body = new ItemBody(BodyType::Text,"--Content goes here--");
$message->ToRecipients = array(
     new Recipient(new EmailAddress("Jon Doe","jdoe@contoso.onmicrosoft.com"))
);
$ctx->getMe()->sendEmail($message,false); //send a Message
$ctx->executeQuery();
```

Changelog
---------

[](#changelog)

1.0.0 - May 23st, 2014

- Initial release.

2.0.0 - February 14, 2016

- `AuthenticationContext` and `ClientContext` classes have been introduced.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 86% 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 ~138 days

Recently: every ~64 days

Total

6

Last Release

2620d ago

### Community

Maintainers

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

---

Top Contributors

[![vgrem](https://avatars.githubusercontent.com/u/1596072?v=4)](https://github.com/vgrem "vgrem (202 commits)")[![blizzz](https://avatars.githubusercontent.com/u/2184312?v=4)](https://github.com/blizzz "blizzz (7 commits)")[![johnpc](https://avatars.githubusercontent.com/u/4824042?v=4)](https://github.com/johnpc "johnpc (6 commits)")[![ctcudd](https://avatars.githubusercontent.com/u/3977194?v=4)](https://github.com/ctcudd "ctcudd (5 commits)")[![mpastas](https://avatars.githubusercontent.com/u/1851992?v=4)](https://github.com/mpastas "mpastas (3 commits)")[![andreybolonin](https://avatars.githubusercontent.com/u/2576509?v=4)](https://github.com/andreybolonin "andreybolonin (2 commits)")[![kevinnkurniawan](https://avatars.githubusercontent.com/u/19869996?v=4)](https://github.com/kevinnkurniawan "kevinnkurniawan (2 commits)")[![prog-24](https://avatars.githubusercontent.com/u/2653516?v=4)](https://github.com/prog-24 "prog-24 (2 commits)")[![thijsvdanker](https://avatars.githubusercontent.com/u/429548?v=4)](https://github.com/thijsvdanker "thijsvdanker (2 commits)")[![pockemul](https://avatars.githubusercontent.com/u/6992719?v=4)](https://github.com/pockemul "pockemul (1 commits)")[![appopcen](https://avatars.githubusercontent.com/u/49448663?v=4)](https://github.com/appopcen "appopcen (1 commits)")[![landrok](https://avatars.githubusercontent.com/u/3310446?v=4)](https://github.com/landrok "landrok (1 commits)")[![nkgokul](https://avatars.githubusercontent.com/u/1375897?v=4)](https://github.com/nkgokul "nkgokul (1 commits)")

---

Tags

apirestcurlOffice365sharepoint

### Embed Badge

![Health badge](/badges/appopcen-php-spo/health.svg)

```
[![Health](https://phpackages.com/badges/appopcen-php-spo/health.svg)](https://phpackages.com/packages/appopcen-php-spo)
```

###  Alternatives

[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.2M267](/packages/nategood-httpful)[vgrem/php-spo

PHP Office 365 library. It allows to performs CRUD operations against Office 365 resources via an REST/OData based API

3741.4M5](/packages/vgrem-php-spo)[tcdent/php-restclient

A generic REST API client for PHP

3542.9M29](/packages/tcdent-php-restclient)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69114.3k](/packages/serpapi-google-search-results-php)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)[msankhala/parsehub-php

Php wrapper classes for Parsehub REST api.

1312.4k](/packages/msankhala-parsehub-php)

PHPackages © 2026

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