Download the PHP package owncloud/ocis-php-sdk without Composer
On this page you can find all versions of the php package owncloud/ocis-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ocis-php-sdk
ocis-php-sdk
This SDK allows you to interact with ownCloud Infinite Scale (oCIS) storage using PHP.
Documentation
You can find a rendered version of the API documentation in our dev docs.
To render the documentation locally, use the phpDocumentor to run it in the local repo. E.g.:
After that you will find the documentation inside the docs
folder.
Installation via Composer
Add "owncloud/ocis-php-sdk" to the require
block in your composer.json and then run composer install.
[!WARNING]
The ocis-php-sdk currently relies on a development version of the "owncloud/libre-graph-api-php" package. To ensure proper dependency resolution, it is necessary to set "minimum-stability": "dev" and "prefer-stable": true in your composer.json file.
Alternatively, you can simply run the following from the command line:
Getting started
Ocis has two types of access token, one which is used to interact with drive, group, user, shares etc.(OICD access token) and another which can be used to interact with education endpoints (education access token).
Create an Ocis object using the service Url and an OIDC access token:
Or create an Ocis object to interact with education endpoints using the service Url and an education access token:
At least one access token should be provided to use the SKD.
Acquiring an OICD access token is out of scope of this SDK, but you can find examples for that below.
Also refreshing OICD tokens is not part of the SDK, but after you got a new token, you can update the Ocis object:
Education access token is set when starting the ocis graph server. You can get it using following snippet
Drives (spaces)
Drives can be listed using the getAllDrives
or the getMyDrives
method.
The Drive class is responsible for most file/folder related actions, like listing files, creating folders, uploading files, etc.
Drive Permission
Users/Groups can be invited to drives by specifying permissions. The Drive class has methods to invite Users/Groups, update permission roles and expiration dates, remove users and groups, etc.
Drive invitations are only possible on project drives.
Notifications
Notifications can be listed using the getNotifications
method, which will return an array of Notification
objects representing all active notifications.
The Notification
object can retrieve details of the corresponding notification and mark it as read (delete).
Sharing
Given the correct permissions, an OcisResource
can be shared with a group or a user. To define the access permissions of the receiver every share has to set SharingRole
(s).
Education User
Education Users can only be created, listed and deleted using education access token. If you want to use other APIs you need to use the OICD access token.
Requirements
- PHP 8.1 or higher
- oCIS 5.0.0 or higher
Acquiring an Access Token
For an easier experience in acquiring an access token, several PHP OIDC client libraries are available. The following code snippet showcases how to retrieve an access token with the facile-it/php-openid-client
library.
Install PHP dependencies
You can install the facile-it/php-openid-client library using composer:
Required PHP Libraries
- php-bcmath
- php-gmp
Code Snippet to Fetch an Access Token
If you're working in a development environment where you might need to bypass SSL verification (though this is not advised for production environments), here's how:
To test, simply open a browser and head to http://url-of-this-file.
Development
Integration tests
To run the tests locally
- Install and setup
docker
(min version 24) anddocker compose
(min version 2.21). -
Ensure that the following php dependencies are installed for executing the integration tests:
-
add these lines to your
/etc/hosts
file: -
run whole tests
-
run single test
If something goes wrong, use
make clean
to clean the created containers and volumes.
All versions of ocis-php-sdk with dependencies
sabre/dav Version ^4.6
owncloud/libre-graph-api-php Version dev-main#0e5491aa123a6db48b2f00f90e734961ee8c4aba
ext-json Version *
ext-curl Version *
ext-dom Version *