Download the PHP package ssswang/sharepoint-graph-client without Composer

On this page you can find all versions of the php package ssswang/sharepoint-graph-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sharepoint-graph-client

SharePoint Graph Client

A SharePoint client library for PHP 8, backed by the Microsoft Graph API.

This library is a rewrite of the WeAreArchitect SharePoint OAuth App Client (ssswang/sharepoint-oauth-app-client), which used the legacy SharePoint REST API (_api/web/...) with tokens issued by the Azure Access Control Service (ACS). That stack is deprecated: ACS was retired, and Microsoft recommends the Graph API for all new SharePoint development. This rewrite targets the Graph API exclusively and requires PHP 8.1+.

Requirements

Installation

Azure AD application setup

  1. Register an application in Entra ID (Azure AD) → App registrations.
  2. Grant application permissions (app-only):
    • Sites.ReadWrite.All (all sites), or preferably Sites.Selected (specific sites, granted via the Graph API/PIM by an admin).
    • Add User.Read.All if you need tenant-wide user lookups.
  3. Grant admin consent.
  4. Authenticate with either a client secret or a certificate.

Quick start

The Access Token is requested automatically (and refreshed when expired or rejected mid-flight) using the OAuth 2.0 client credentials flow against the Microsoft identity platform. You can also inject a delegated token obtained elsewhere:

Lists and items

Document libraries, folders and files

Document libraries are addressed as drives:

Users

Configuration reference

Key Description Default
tenant Azure AD Tenant ID (GUID) required
client_id Azure AD application (client) ID required
secret Client secret (or use certificate) null
certificate private_key, private_key_passphrase, thumbprint null
authority Identity platform endpoint (national clouds) https://login.microsoftonline.com/
scope OAuth scope https://graph.microsoft.com/.default
graph Graph endpoint (national clouds) https://graph.microsoft.com/v1.0/
retry.attempts Max attempts for throttled (429) / transient (503, 504) requests 3
retry.delay Fixed delay in seconds (the Retry-After header is used when null) null

Migrating from the SharePoint REST client

Old (SP REST) New (Graph)
SPSite::create($url, $settings) GraphSite::create($url, $settings)
SPSite::createSPAccessToken() automatic (or createGraphAccessToken())
SPAccessToken::createAOP() (ACS) GraphAccessToken::create() (identity platform)
SPAccessToken::createUOP() (context token) not applicable — use a delegated token via setGraphAccessToken()
SPSite::createSPFormDigest() removed — the Graph API has no form digests
SPList::getAll/getByTitle/getByGUID() same names on GraphList
SPList::createSPItem()/getSPItems() GraphList::createGraphItem()/getGraphItems()
SPItem::getByID/getByTitle() GraphItem::getByID/getByTitle()
SPFolder::getByRelativeUrl() GraphDrive::getGraphFolderByPath() (drive-root relative)
SPFile::getByRelativeUrl() GraphFile::getByPath()
SPFile::getByName() same name on GraphFile
SPFile::create() same name (+ createResumable() for large files)
SPFile::start()/continue()/finish() GraphUploadSession::uploadChunk()/upload()
SPFile::move()/copy()/delete()/update() same names on GraphFile
SPFile::recycle() removed — no Graph equivalent
SPFile::createByTemplate() removed — use copy() from a template file
SPList::createSPField() (FieldTypeKind) GraphList::createGraphColumn() (Graph column schema)
SPUser::getCurrent()/getByAccount() same names on GraphUser
server-relative URLs (/sites/x/Shared Docs) drive-root relative paths (Shared Docs)
items keyed by GUID items keyed by Graph item ID

Behavioural notes

Examples

A runnable live-API test script is included: it creates a folder, uploads a file with a Unicode-heavy name (Lastäåãæ, Firstëêēèéßæãùóœ, X999999) containing random text, downloads it again and verifies the content round trip. All connection details are supplied by the user on the command line:

Troubleshooting

SSL certificate problem: unable to get local issuer certificate (cURL error 60)

Windows PHP builds ship without a CA certificate bundle. Download the standard bundle and point php.ini at it:

Alternatively, pass a bundle (or false, not recommended for production) per client through the Guzzle options: ['http' => ['verify' => '/path/to/cacert.pem']].

A second live-API script, examples/list-test.php (wrapper: list-test.bat), takes the name of a document library (Drive), reads the structure of the list behind it (columns, types, required), and adds a new item to the list — for document libraries it uploads a small file and sets the column values on its list item, since raw list items cannot be created there:

A third live-API script, examples/delete-item.php (wrapper: delete-item.bat), deletes a list item by name in a given document library (Drive). In document libraries the name is matched as a file path relative to the drive root, then as an item Title, then as the file name (FileLeafRef); other lists match on Title. The item is shown first and deleted after a confirmation prompt (--yes skips it), and the deletion is verified afterwards:

Testing

The test suite runs on PHP 8.4+ (PHPUnit 13); the library itself supports PHP 8.1+.

The suite runs fully offline: HTTP responses are queued with Guzzle's MockHandler, so every request-layer behaviour (authentication, throttling retries, pagination, upload sessions, async copy monitoring) is exercised without touching the real Microsoft Graph API.

License

MIT — see the LICENSE file. Based on the SharePoint OAuth App Client by Quetzy Garcia (Architect 365); Graph rewrite by Song Wang.


All versions of sharepoint-graph-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^8.1
firebase/php-jwt Version ^7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ssswang/sharepoint-graph-client contains the following files

Loading the files please wait ...