The Comfortable PHP SDK can be installed with Composer. Run this command:
composer require comfortable/php-sdk


Note: This version of the SDK requires PHP 5.6 or greater.

Include the dependency:

require_once __DIR__ . '/vendor/autoload.php'; // change path as needed
use Comfortable;

Connect to your Repository and make your first request:

$api = Comfortable\Api::connect('<repository-api-id>', '<api-key>');
try {
// get all documents stored in comfortable (default limit: 25)
$results = $api->getDocuments()->execute();
} catch (\RuntimeException $e) {
echo 'Comfortalbe SDK returned an error: ' . $e->getMessage();

Full usage Example

use Comfortable\Api;
use Comfortable\Filter;
use Comfortable\Sorting;
use Comfortable\Includer;
// connect to your repository
$api = Api::connect('<repository-api-id>', '<api-key>');
$results = $api->getDocuments()
->limit(10) // limits the result to 10
->offset(25) // skip the first 25 documents
->locale('en') // receive the document in english
->includes(2) // includes 2 levels of relations
(new Includer)
->add('relatedNews') // include only the relatedNews instead of all relations
->embedAssets(true) // embed assets directly inside a document instead of using them as includes
->includeTags(["include", "me"]) // include documents with the "include" or "me" tag
->excludeTags(["exclude"]) // exclude documents with the "exclude" tag
->search('this is a fulltext search') // perform a fulltext search
->fields('fields(title)') // name the fields you want to receive by the api
(new Sorting)
->add('id', 'ASC', 'meta') // sort the result ascending by id
->add('title', 'DESC') // sort the result descending by title
(new Filter)
->addAnd('date', 'greaterThan', '01-02-2018') // return only documents greaterThan given date