CloudObjects SDK for PHP for working with COIDs and object descriptions from CloudObjects.

dev-main 2023-07-03 15:24 UTC

This package is auto-updated.

Last update: 2023-09-03 15:55:08 UTC


Latest Stable Version Total Downloads

buddy branch

The CloudObjects PHP SDK provides simple access to CloudObjects from PHP-based applications. It wraps the Object API to fetch objects from the CloudObjects Core database and provides object-based access to their RDF description. A two-tiered caching mechanism (in-memory and Doctrine cache drivers) is included. The SDK also contains a helper class to validate COIDs.


The SDK is distributed through packagist. Add cloudobjects/sdk to the require section of your composer.json, like this:

  "require": {
    "cloudobjects/sdk" : ">=0.7"

Retrieving Objects

In order to retrieve objects from the CloudObjects Core database you need to create an instance of CloudObjects\SDK\ObjectRetriever. Then you can call getObject(). This method returns an ML\JsonLD\Node instance or null if the object is not found. You can use the object interface of the JsonLD library to read the information from the object.

Here's a simple example:

use CloudObjects\SDK\ObjectRetriever;

/* ... */

$retriever = new ObjectRetriever();
$object = $this->retriever->getObject(new IRI('coid://'));
if (isset($object))
    echo $object->getProperty('')->getValue();
    echo "Object not found.";


You can pass an array of configuration options to the ObjectRetriever's constructor:

cache_providerThe type of cache used. Currently supports redis, file and none.none
cache_prefixA prefix used for cache IDs. Normally this should not be set but might be necessary on shared caches.clobj:
cache_ttlDetermines how long objects can remain cached.60
auth_nsThe namespace of the service that this retriever acts for. If not set the API is accessed anonymously.null
auth_secretThe shared secret between the namespace in auth_ns and for authenticated. If not set the API is accessed anonymously.null

For redis cache:

cache_provider.redis.hostThe hostname or IP of the Redis instance.
cache_provider.redis.portThe port number of the Redis instance.6379

For file cache:

cache_provider.file.directoryThe directory to store cache data in.The system's temporary directory.


The PHP SDK is licensed under Mozilla Public License (see LICENSE file).