clusterpoint/php-client-api-v4

4.0.28 2016-11-17 13:33 UTC

README

License Total Downloads Latest Stable Version Latest Unstable Version

Clusterpoint is a NoSQL document database known for its innovative Cloud-based distributed architecture, fast processing speed, and a flexible "pay as you use" pricing model. The database also features a developer-friendly API suitable for many popular modern programming languages, including PHP -- the specific API which is the focus of this document. Its full support for ACID-compliant transactions is a rarity among NoSQL databases, making the product useful for situations where data integrity is a must.

The recently introduced fourth edition of Clusterpoint added a unique JavaScript/SQL query language with computational capabilities,, allowing you to create powerful queries to store, retrieve, and transform data. The PHP API is flexible enough to allow you to use either interface methods or raw JS/SQL queries to accomplish your database tasks. The decision to use either approach ultimately depends on programmer preference and the individual development scenario.

Clusterpoint 4.x PHP Client API

Official Documentation

Documentation for the API can be found on the Clusterpoint website.

Requirements

PHP >= 5.4.0
cURL PHP Extension
Composer

Getting Started

  1. Sign up for Clusterpoint – Before you begin, you need to sign up for a Clusterpoint account and retrieve your Clusterpoint credentials.
  2. Minimum requirements – To run the PHP Client API, your system will need to meet the minimum requirements, including having **PHP >= 5.4.0 compiled with the cURL extension and cURL 4.0.2+.
  3. Install the APIComposer is the right way to install the PHP Client API.
    composer require clusterpoint/php-client-api-v4
  4. Publish config file - this is optional step, you can pass access points during workflow, but this might make your development process easier.
    php -r "copy('vendor/clusterpoint/php-client-api-v4/src/config.example', 'clusterpoint.php');"
  5. Access – You can pass the credentials inside on Clusterpoint\Client class construction, or use clusterpoint.php inside your project root folder, to manage your access points.

Quick Example

<?php
require 'vendor/autoload.php';
// or if you installed api without composer:
// require 'api_install_folder/Clusterpoint.php'

use Clusterpoint\Client;

//Initialize the service
$cp = new Client([
	'host' => 'https://api-eu.clusterpoint.com/v4',
	'account_id' => '1',
	'username' => 'root',
	'password' => 'password',
	'debug' => true,
]);

// Set the database.collection to initalize the query builder for it.
$bikes = $cp->database("shop.bikes");

// Build your query
$results = $bikes->where('color', 'red')
	->where('availability', true)
	->limit(5)
	->groupBy('category')
	->orderBy('price')
	->select(['name', 'color', 'price', 'category'])
	->get();

// Access your results
echo "First bike price: ".$results[0]->price;

Support, Feature Requests & Bug Reports

License

Clusterpoint 4.x PHP Client API is open-sourced software licensed under the MIT license