PHPackages                             thybag/php-sharepoint-lists-api - 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. thybag/php-sharepoint-lists-api

ActiveLibrary[API Development](/categories/api)

thybag/php-sharepoint-lists-api
===============================

A simple PHP API to make working with SharePoint lists easy.

0.7.3(3y ago)189148.4k—6%95[45 issues](https://github.com/thybag/PHP-SharePoint-Lists-API/issues)[3 PRs](https://github.com/thybag/PHP-SharePoint-Lists-API/pulls)MITPHPPHP ^7.1 || ^8.0

Since Sep 30Pushed 3y ago20 watchersCompare

[ Source](https://github.com/thybag/PHP-SharePoint-Lists-API)[ Packagist](https://packagist.org/packages/thybag/php-sharepoint-lists-api)[ Docs](https://github.com/thybag/PHP-SharePoint-Lists-API)[ RSS](/packages/thybag-php-sharepoint-lists-api/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (7)DependenciesVersions (10)Used By (0)

PHP SharePoint Lists API
========================

[](#php-sharepoint-lists-api)

The **PHP SharePoint Lists API** is designed to make working with SharePoint Lists in PHP a less painful developer experience. Rather than messing around with SOAP and CAML requests, just include the SharePoint lists API in to your project and you should be good to go. This library is free for anyone to use and is licensed under the MIT license.

Using the PHP SharePoint Lists API, you can easily create, read, edit and delete from SharePoint list. The API also has support for querying list metadata and the list of lists.

Known to work with: SharePoint 2007, SharePoint 2013 and SharePoint online (experimental).

### Usage Instructions

[](#usage-instructions)

#### Installation

[](#installation)

Download the WSDL file for the SharePoint Lists you want to interact with. This can normally be obtained at: `sharepoint.url/subsite/_vti_bin/Lists.asmx?WSDL`

If you are using [composer](http://getcomposer.org/), just add [thybag/php-sharepoint-lists-api](https://packagist.org/packages/thybag/php-sharepoint-lists-api) to your `composer.json` and run composer.

```
{
    "require": {
        "thybag/php-sharepoint-lists-api": "dev-master"
    }
}

```

If you are not using composer you can download a copy of the SharePointAPI files manually and include the top "SharePointAPI.php" class in your project.

#### Creating SharePointAPI object

[](#creating-sharepointapi-object)

In order to use the PHP SharePoint Lists API you will need a valid user/service account with the permissions to the required list.

For most SharePoint installations, you can create a new instance of the API using:

```
use Thybag\SharePointAPI;
$sp = new SharePointAPI('', '', '');

```

If your installation requires NTLM Authentication, you can instead use:

```
use Thybag\SharePointAPI;
$sp = new SharePointAPI('', '', '', 'NTLM');

```

SharePoint Online users must use:

```
use Thybag\SharePointAPI;
$sp = new SharePointAPI('', '', '', 'SPONLINE');

```

All methods return an Array by default. `SetReturnType` can be used to specify that results should be returned as objects instead.

#### Reading from a List.

[](#reading-from-a-list)

###### To return all items from a list use either

[](#to-return-all-items-from-a-list-use-either)

```
$sp->read('');

```

or

```
$sp->query('')->get();

```

###### To return only the first 10 items from a list use:

[](#to-return-only-the-first-10-items-from-a-list-use)

```
$sp->read('', 10);

```

or

```
$sp->query('')->limit(10)->get();

```

###### To return all the items from a list where surname is smith use:

[](#to-return-all-the-items-from-a-list-where-surname-is-smith-use)

```
$sp->read('', NULL, array('surname'=>'smith'));

```

or

```
$sp->query('')->where('surname', '=', 'smith')->get();

```

###### To return the first 5 items where the surname is smith and the age is 40

[](#to-return-the-first-5-items-where-the-surname-is-smith-and-the-age-is-40)

```
$sp->read('', 5, array('surname'=>'smith','age'=>40));

```

or

```
$sp->query('')->where('surname', '=', 'smith')->and_where('age', '=', '40')->limit(5)->get();

```

###### To return the first 10 items where the surname is "smith" using a particular view, call: (It appears views can only be referenced by their GUID)

[](#to-return-the-first-10-items-where-the-surname-is-smith-using-a-particular-view-call-it-appears-views-can-only-be-referenced-by-their-guid)

```
$sp->read('', 10, array('surname'=>'smith','age'=>40),'{0FAKE-GUID001-1001001-10001}');

```

or

```
 $sp->query('')->where('surname', '=', 'smith')->and_where('age', '=', '40')->limit(10)->using('{0FAKE-GUID001-1001001-10001}')->get();

```

###### To return the first 10 items where the surname is smith, ordered by age use:

[](#to-return-the-first-10-items-where-the-surname-is-smith-ordered-by-age-use)

```
$sp->read('', 10, array('surname'=>'smith'), NULL, array('age' => 'desc'));

```

or

```
$sp->query('')->where('surname', '=', 'smith')->limit(10)->sort('age','DESC')->get();

```

###### To return the first 5 items, including the columns "favroite\_cake" and "favorite animal"

[](#to-return-the-first-5-items-including-the-columns-favroite_cake-and-favorite-animal)

```
$sp->read('', 5, NULL, array("favroite_cake", "favorite_animal"));

```

or

```
$sp->query('')->fields(array("favroite_cake", "favorite_animal")->limit(5)->get();

```

By default list item's are returned as arrays with lower case index's. If you would prefer the results to return as object's, before invoking any read operations use:

```
$sp->setReturnType('object');

```

Automatically making the attribute names lowercase can also be deactivated by using:

```
$sp->lowercaseIndexs(FALSE);

```

#### Querying a list

[](#querying-a-list)

The query method can be used when you need to specify a query that is to complex to be easily defined using the read methods. Queries are constructed using a number of (hopefully expressive) pseudo SQL methods.

If you for example wanted to query a list of pets and return all dogs below the age of 5 (sorted by age) you could use.

```
$sp->query('list of pets')->where('type','=','dog')->and_where('age','update('','5', array('forename'=>'James'));

```

As with the write method you can also run multiple update operations together by using:

```
$sp->updateMultiple('', array(
	array('ID'=>5,'job'=>'Intern'),
	array('ID'=>6,'job'=>'Intern')
));

```

When using updateMultiple every item MUST have an ID.

> ❗ This method returns the row that has been updated. It does not always return the updated data, as SharePoint can take longer to update than this method takes to run. It is therefore not recommended to use this as a check to ensure a successful update.

#### Deleting Rows

[](#deleting-rows)

In order to delete a row, an ID as well as list name is required. To remove the record for James with the ID 5 you would use:

```
$sp->delete('', '5');

```

If you wished to delete a number of records at once, an array of ID's can also be passed to the delete multiple method

```
$sp->deleteMultiple('', array('6','7','8'));

```

#### CRUD - Create, Read, Update and Delete

[](#crud---create-read-update-and-delete)

The above actions can also be performed using the CRUD wrapper on a list. This may be useful when you want to perform multiple actions on the same list. Crud methods do not require a list name to be passed in.

```
$list = $sp->CRUD('');
$list->read(10);
$list->create(array( 'id'=>1, 'name'=>'Fred' ));

```

#### List all Lists.

[](#list-all-lists)

You can get a full listing of all available lists within the connected SharePoint subsite by calling:

```
$sp->getLists();

```

#### List metaData.

[](#list-metadata)

You can access a lists meta data (Column configuration for example) by calling

```
$sp->readListMeta('My List');

```

By default the method will attempt to strip out non-useful columns from the results, but keep "hidden". If you'd like the full results to be returned call:

```
$sp->readListMeta('My List',FALSE);

```

You can also now ignore "hidden" columns:

```
$sp->readListMeta('My List', FALSE, TRUE);

```

#### Field history / versions.

[](#field-history--versions)

If your list is versioned in SharePoint, you can read the versions for a specific field using:

```
$sp->getVersions('', '', '');

```

#### Attach a file to a SharePoint list item

[](#attach-a-file-to-a-sharepoint-list-item)

Files can be attached to SharePoint list items using:

```
$sp->addAttachment('', '', '');

```

### Helper methods

[](#helper-methods)

The PHP SharePoint API contains a number of helper methods to make it easier to ensure certain values are in the correct format for some of SharePoints special data types.

###### dateTime

[](#datetime)

The dataTime method can either be passed a text based date

```
 $date = \Thybag\SharepointApi::dateTime("2012-12-21");

```

Or a unix timestamp

```
$date = \Thybag\SharepointApi::dateTime(time(), true);

```

And will return a value which can be stored in to SharePoints DateTime fields without issue.

###### Lookup

[](#lookup)

The lookup data type in SharePoint is for fields that reference a row in another list. In order to correctly populate these values you will need to know the ID of the row the value needs to reference.

```
$value = \Thybag\SharepointApi::lookup('3','Pepperoni Pizza');

```

If you do not know the name/title of the value you are storing the method will work fine with just an ID (which SharePoint will also accept directly)

```
$value = \Thybag\SharepointApi::lookup('3');

```

###### Magic Lookup

[](#magic-lookup)

If you are attempting to store a value in a "lookup" data type but for some reason only know the title/name of the item, not its ID, you can use the MagicLookup method to quickly look this value up and return it for you. This method will need to be passed both the items title &amp; the list it is contained within.

```
$sp->magicLookup("Pepperoni Pizza", "Pizza List");

```

Trouble shooting
----------------

[](#trouble-shooting)

- Unable to find the wrapper "https"

If you are getting this error it normally means that php\_openssl (needed to curl https urls) is not enabled on your webserver. With many local websevers (such as XAMPP) you can simply open your php.ini file and uncomment the php\_openssl line (ie. remove the ; before it).

Note: If you are using SharePoint Online and having SSL errors, please pull the latest version which has changed from SSL v3 to TLS for sharepoint online connections -

Add this line to your `composer.json` file.

```
 "thybag/php-sharepoint-lists-api": "dev-develop"

```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 58.5% 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 ~566 days

Recently: every ~653 days

Total

7

Last Release

1214d ago

### Community

Maintainers

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

---

Top Contributors

[![thybag](https://avatars.githubusercontent.com/u/887397?v=4)](https://github.com/thybag "thybag (120 commits)")[![Quix0r](https://avatars.githubusercontent.com/u/470798?v=4)](https://github.com/Quix0r "Quix0r (64 commits)")[![kasperg](https://avatars.githubusercontent.com/u/73966?v=4)](https://github.com/kasperg "kasperg (4 commits)")[![csmithmedia](https://avatars.githubusercontent.com/u/289157?v=4)](https://github.com/csmithmedia "csmithmedia (3 commits)")[![cweiske](https://avatars.githubusercontent.com/u/59036?v=4)](https://github.com/cweiske "cweiske (1 commits)")[![dbirler](https://avatars.githubusercontent.com/u/186709021?v=4)](https://github.com/dbirler "dbirler (1 commits)")[![dnna](https://avatars.githubusercontent.com/u/1296821?v=4)](https://github.com/dnna "dnna (1 commits)")[![fernandosantini](https://avatars.githubusercontent.com/u/16956749?v=4)](https://github.com/fernandosantini "fernandosantini (1 commits)")[![andrew-kzoo](https://avatars.githubusercontent.com/u/2422378?v=4)](https://github.com/andrew-kzoo "andrew-kzoo (1 commits)")[![jna-unikent](https://avatars.githubusercontent.com/u/4138097?v=4)](https://github.com/jna-unikent "jna-unikent (1 commits)")[![kcjones](https://avatars.githubusercontent.com/u/4297780?v=4)](https://github.com/kcjones "kcjones (1 commits)")[![luffy-xiao](https://avatars.githubusercontent.com/u/1563538?v=4)](https://github.com/luffy-xiao "luffy-xiao (1 commits)")[![mgroat](https://avatars.githubusercontent.com/u/299183?v=4)](https://github.com/mgroat "mgroat (1 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (1 commits)")[![jackfruh](https://avatars.githubusercontent.com/u/334880?v=4)](https://github.com/jackfruh "jackfruh (1 commits)")[![BinaryZeph](https://avatars.githubusercontent.com/u/1881334?v=4)](https://github.com/BinaryZeph "BinaryZeph (1 commits)")[![Burgov](https://avatars.githubusercontent.com/u/417674?v=4)](https://github.com/Burgov "Burgov (1 commits)")[![cdcastro](https://avatars.githubusercontent.com/u/5162452?v=4)](https://github.com/cdcastro "cdcastro (1 commits)")

### Embed Badge

![Health badge](/badges/thybag-php-sharepoint-lists-api/health.svg)

```
[![Health](https://phpackages.com/badges/thybag-php-sharepoint-lists-api/health.svg)](https://phpackages.com/packages/thybag-php-sharepoint-lists-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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