Giter Site home page Giter Site logo

communibase-connector-php's Introduction

Scrutinizer Quality Score Latest Stable Version License

A general-purpose Communibase client for PHP projects, compatible with composer packaging-projects.

A connector may be constructed to do REST-calls on the Communibase API. The behaviour of this class should always Mimic the node.js-version, available at Github

Usage

The easiest way to install the connector is to use Composer and add the following to your project's composer.json file:

{
    "require": {
        "kingsquare/communibase-connector-php": "~1"
    }
}

Now you should be able to install the package by updating your composer environment composer install The connector is available and usable as follows:

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload
use Communibase\Connector;

$cb = new Connector('<your api key here>');
$peopleNamedTim = $db->search('Person', array('firstName' => 'Tim'), array('limit' => 5));
print_r($peopleNamedTim);

API

"entityType" should be the Communibase Entitytype, e.g. "Person", "Invoice", etc. To see all the entity types your API key allows, see the API docs and insert your API key there.

"selectors" may be provided MongoDb style as array-definitions.

"params" is a key value store for e.g. fields, limit, page and/or sort . See API docs for more details. In addition to the nodeJS version of this paramater, the fields value may also be an array of fields. This will work more intuitively in PHP environments.


$cbc->search($entityType, $selector, $params): entity[];

$cbc->getAll($entityType, $params): entity[];

$cbc->getById($entityType, $id, $params): entity;

$cbc->getByIds($entityType, $ids, $params): entity[];

$cbc->getId($entityType, $selector): string;

$cbc->getIds($entityType, $selector, $params): null|string[];

$cbc->getByRef($ref[, $parent]): entity

$cbc->getTemplate($entityType): array;

$cbc->getHistory($entityType, $id): array;

$cbc->update($entityType, $properties): responseData;

$cbc->destroy($entityType, $id): responseData;

$cbc->generateId(): string - Generate a new, fresh Communibase ID

//Use for Files only to get a string with the binary contents
$cbc->getBinary(id): string;

Whenever a function like getByIds() or getByIds() returns null, the property cbc->lastError should be available containing an error message

Entity

An entity is an associative array containing a key/value store of data in Communibase.

E.g.

array(
	'firstName' => 'Tim',
	'addresses' => array(
		array (
			'street' => 'Breestraat'
			...
		), ...
	)
)

ResponseData

Response data is an associative array in the following format:

array(
	success => true|false
	errors => array(
		array(
			'field' => '<string>',
			'message' => '<string>'
		)
	)
)

communibase-connector-php's People

Contributors

fruitl00p avatar reggino avatar scrutinizer-auto-fixer avatar

Watchers

Misha van Tol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.